v0.13.0-beta.1 #679
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish Docker image | |
on: | |
push: | |
branches: [main, beta] | |
release: | |
types: | |
- published | |
jobs: | |
npm_build_frontend: | |
name: Build frontend | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
id: cache | |
env: | |
cache-name: cache-node-modules-frontend-v2 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }} | |
- name: Cache npm cache | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-npm-cache-frontend-v2 | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
- name: Install frontend dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: npm ci --prefer-offline --no-audit | |
- name: Build frontend | |
run: npm run build | |
npm_build_backend: | |
name: Build backend | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./backend | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
id: cache | |
env: | |
cache-name: cache-node-modules-backend-v2 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('backend/package-lock.json') }} | |
- name: Cache npm cache | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-npm-cache-backend-v2 | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('backend/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
- name: Install backend dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: npm ci --prefer-offline --no-audit | |
- name: Link backend dependencies in `/common` | |
run: ln -s ../backend/node_modules ../common/node_modules | |
- name: Build backend | |
run: npm run build | |
push_to_registry: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
needs: | |
- npm_build_frontend | |
- npm_build_backend | |
steps: | |
- name: Docker meta | |
id: docker_meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: jojomatik/blockcluster | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} | |
type=sha | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
cache-from: type=gha,scope=blockcluster | |
cache-to: type=gha,scope=blockcluster,mode=max | |
build-args: | | |
git_sha=${{github.sha}} | |
git_ref=${{github.ref}} | |
semantic-release: | |
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta' }} | |
name: Create a semantic release | |
runs-on: ubuntu-latest | |
needs: | |
- npm_build_frontend | |
- npm_build_backend | |
- push_to_registry | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
id: cache | |
env: | |
cache-name: cache-node-modules-frontend-v2 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }} | |
- name: Cache npm cache | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-npm-cache-frontend-v2 | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
- name: Install frontend dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: npm ci --prefer-offline --no-audit | |
- name: Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | |
GIT_AUTHOR_NAME: ${{ secrets.BUMP_GIT_NAME }} | |
GIT_AUTHOR_EMAIL: ${{ secrets.BUMP_GIT_EMAIL }} | |
GIT_COMMITTER_NAME: ${{ secrets.BUMP_GIT_NAME }} | |
GIT_COMMITTER_EMAIL: ${{ secrets.BUMP_GIT_EMAIL }} | |
run: npm run semantic-release | |
sync_main_to_beta: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
name: Sync branch `main` to `beta` (fast-forward enabled) | |
runs-on: ubuntu-latest | |
needs: | |
- semantic-release | |
steps: | |
- name: Keep `beta` up to date with `main` (fast-forward enabled) | |
uses: jojomatik/sync-branch@v2 | |
with: | |
git_committer_name: ${{ secrets.BUMP_GIT_NAME }} | |
git_committer_email: ${{ secrets.BUMP_GIT_EMAIL }} | |
github_token: ${{ secrets.GH_TOKEN }} | |
sync_beta_to_updates: | |
if: ${{ github.ref == 'refs/heads/beta' }} | |
name: Sync branch `beta` to `updates` (fast-forward enabled) | |
runs-on: ubuntu-latest | |
needs: | |
- semantic-release | |
steps: | |
- name: Keep `updates` up to date with `beta` (fast-forward enabled) | |
uses: jojomatik/sync-branch@v2 | |
with: | |
target: "updates" | |
git_committer_name: ${{ secrets.BUMP_GIT_NAME }} | |
git_committer_email: ${{ secrets.BUMP_GIT_EMAIL }} | |
github_token: ${{ secrets.GH_TOKEN }} |