livebook/.github/workflows/deploy.yaml

91 lines
2.7 KiB
YAML
Raw Normal View History

2021-05-26 21:38:25 +08:00
name: Deploy
on:
push:
branches:
- main
tags:
- 'v*.*.*'
jobs:
assets:
outputs:
sha: ${{ steps.push_assets.outputs.commit_hash }}
2021-05-26 21:38:25 +08:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Erlang & Elixir
uses: erlef/setup-beam@v1
with:
otp-version: '24.0'
elixir-version: '1.13.0'
2021-05-26 21:38:25 +08:00
- name: Cache Mix
uses: actions/cache@v2
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-
# Note: we need to get Phoenix and LV because package.json points to them directly
- name: Install mix dependencies
run: mix deps.get
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '14.x'
- name: Cache npm dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Clean generated assets
run: rm -rf static/{js,css}
2021-05-26 21:38:25 +08:00
- name: Install npm dependencies
run: npm ci --prefix assets
- name: Build assets
run: npm run deploy --prefix assets
- name: Push updated assets
id: push_assets
2021-05-26 21:38:25 +08:00
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update assets
file_pattern: static
2021-05-26 21:38:25 +08:00
docker:
# The assets job may push new commit, so we wait for it
needs: [assets]
2021-05-26 21:38:25 +08:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# The output is set only if there was a commit, otherwise
# we pass an empty ref and and the default is used
ref: ${{ needs.assets.outputs.sha }}
2021-05-26 21:38:25 +08:00
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: livebook/livebook
tags: |
type=semver,pattern={{version}}
type=edge,branch=main
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
2021-11-10 02:40:09 +08:00
cache-from: type=gha
cache-to: type=gha,mode=max