BUG Deploy #143
This file contains hidden or 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: BUG Deploy | |
| env: | |
| registry: "ghcr.io" | |
| on: | |
| workflow_run: | |
| workflows: ["Version Bump"] | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| docker: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./src/server | |
| steps: | |
| # checkout the repository at the latest commit | |
| - name: checkout repository | |
| uses: actions/checkout@v6 | |
| # setup node | |
| - name: setup node | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| # install dependencies | |
| - name: install dependencies | |
| run: npm ci | |
| # set build timestamp | |
| - name: set build timestamp | |
| run: echo "timestamp=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV | |
| # get backend version | |
| - name: get backend version | |
| id: backend-version | |
| uses: martinbeentjes/npm-get-version-action@v1.1.0 | |
| with: | |
| path: ./ | |
| # print version | |
| - name: print backend version | |
| run: echo "building server image with version ${{ steps.backend-version.outputs.current-version }}" | |
| # setup qemu for multi-platform builds | |
| - name: set up qemu | |
| uses: docker/setup-qemu-action@v3 | |
| # setup docker buildx | |
| - name: set up docker buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| buildkitd-flags: --debug | |
| # login to GHCR | |
| - name: login to ghcr | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.registry }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| logout: false | |
| # build and push server image | |
| - name: build and push server image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: "." | |
| file: ./src/server/Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| ${{ env.registry }}/${{ github.repository_owner }}/bug:${{ steps.backend-version.outputs.current-version }} | |
| ${{ env.registry }}/${{ github.repository_owner }}/bug:latest | |
| labels: | | |
| author=${{ github.actor }} | |
| version=${{ steps.backend-version.outputs.current-version }} | |
| org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
| uk.co.bbc.bug.build.timestamp=${{ env.timestamp }} | |
| uk.co.bbc.bug.build.number=${{ github.run_number }} | |
| uk.co.bbc.bug.build.commit=${{ github.sha }} |