Skip to content

Merge branch 'main' of https://github.com/bbc/bug #49

Merge branch 'main' of https://github.com/bbc/bug

Merge branch 'main' of https://github.com/bbc/bug #49

Workflow file for this run

name: BUG Deploy
env:
registry: "ghcr.io"
on:
workflow_dispatch:
push:
branches:
- main
tags:
- "v*"
paths:
- "package*.json"
- "src/client/**"
- "src/modules/**"
- "src/server/**"
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
defaults:
run:
working-directory: ./src/server
steps:
# get the latest version of the repository
- name: Checkout
uses: actions/checkout@v6
- uses: actions/setup-node@v6
# get current date and time for build
- name: Set current date and time as an environment variable
run: echo "timestamp=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
- name: Print current date and time
run: echo ${{ env.timestamp }}
# get the package.json version
- uses: martinbeentjes/npm-get-version-action@master
name: Get Backend Version
id: backend-version
with:
path: ./
- uses: martinbeentjes/npm-get-version-action@master
name: Get Frontend Version
id: frontend-version
with:
path: ./src/client
- name: Print Current Versions
run: echo Building BUG with backend version ${{ steps.backend-version.outputs.current-version }} and frontend version ${{ steps.frontend-version.outputs.current-version }}
# docker buildx setup
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
- name: List available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
# docker registry login
- name: Login to GHCR Registry
uses: docker/login-action@v3
with:
registry: ${{ env.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: false
# docker build image and push to registry
- name: Build and push to registry
uses: docker/build-push-action@v6
with:
context: "."
file: ./src/server/Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ steps.backend-version.outputs.current-version != '' && format('{0}/{1}/bug:{2}', env.registry, github.repository_owner, steps.backend-version.outputs.current-version) || '' }}
${{ github.ref == 'refs/heads/main' && format('{0}/{1}/bug:latest', env.registry, github.repository_owner) || '' }}
outputs: type=registry
labels: |
author=${{github.actor}}
version=${{steps.backend-version.outputs.current-version}}
org.opencontainers.image.licenses=Apache-2.0
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.id=${{github.run_id}}
uk.co.bbc.bug.build.branch=${{github.ref_name}}
uk.co.bbc.bug.build.commit=${{github.sha}}
uk.co.bbc.bug.build.repository=${{github.server_url}}/${{github.repository}}