Skip to content
Merged
36 changes: 17 additions & 19 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ on:
env:
REGISTRY: ghcr.io
jobs:
debug:
if: (github.event.issue.pull_request && contains(github.event.comment.body, '/debug'))
runs-on: ubuntu-latest
steps:
- name: Get PR branch
id: pr-branch
uses: xt0rted/pull-request-comment-branch@v3
- name: Echo PR Base Branch
run: echo "The base branch for this PR is ${{ toJson(steps.pr-branch.outputs) }}"
buildx:
if: |
github.event.pull_request.merged == true ||
Expand All @@ -36,6 +27,11 @@ jobs:
matrix:
images: ${{ fromJson(vars.IMAGES) }}
steps:
- name: Get PR branch
if: github.event.issue.pull_request
id: pr-branch
uses: xt0rted/pull-request-comment-branch@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand All @@ -51,7 +47,7 @@ jobs:
- uses: actions/checkout@v4
if: ( github.event.issue.pull_request && contains(github.event.comment.body, '/build') )
with:
ref: refs/pull/${{ github.event.issue.number }}/head
ref: ${{ steps.pr-branch.outputs.head_ref }}

- name: Login to registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
Expand All @@ -66,25 +62,26 @@ jobs:
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.images }}
context: ${{ github.event.issue.pull_request && 'workflow' || 'git' }}
tags: |
# PR images (not merged): pr-<num>
type=ref,event=pr,enable=${{ github.event.pull_request.merged == false }}
# Tag with the PR base branch name on merge
type=raw,value=${{ github.event.pull_request.base.ref }},enable=${{ github.event.pull_request.merged == true }}
# Manual/scheduled runs tag by branch ref (for whichever release branch the run targets)
# Manual/scheduled runs tag by branch ref
type=ref,event=branch,enable=${{ contains(fromJson('["schedule", "workflow_dispatch"]'), github.event_name) }}
# Comment-triggered builds: pr-<num>
type=raw,event=default,value=pr-${{ github.event.issue.number }},enable=${{ github.event.issue.pull_request != null }}
# Supported release branches
type=raw,value=5.x,enable=${{ github.ref == 'refs/heads/5.x' || github.event.pull_request.base.ref == '5.x' }}
type=raw,value=6.x,enable=${{ github.ref == 'refs/heads/6.x' || github.event.pull_request.base.ref == '6.x' }}
type=raw,value=7.x,enable=${{ github.ref == 'refs/heads/7.x' || github.event.pull_request.base.ref == '7.x' }}
type=raw,value=pr-${{ github.event.issue.number }},enable=${{ github.event.issue.pull_request != null }}
# Supported release branches - use the fetched branch name for comments
type=raw,value=5.x,enable=${{ github.ref_name == '5.x' || github.event.pull_request.base.ref == '5.x' || ! steps.pr-branch.outputs.head_ref }}
type=raw,value=6.x,enable=${{ github.ref_name == '6.x' || github.event.pull_request.base.ref == '6.x' || ! steps.pr-branch.outputs.head_ref }}
type=raw,value=7.x,enable=${{ github.ref_name == '7.x' || github.event.pull_request.base.ref == '7.x' || ! steps.pr-branch.outputs.head_ref }}
# Always add an immutable sha tag
type=raw,value=sha-${{ github.sha }}
type=raw,value=sha-${{ github.event.pull_request.head.sha || steps.pr-branch.outputs.head_sha || github.sha }}
labels: |
maintainer=Digital Victoria
maintainer=Victorian Department of Government Services
repository=${{ github.repositoryUrl }}
org.opencontainers.image.authors=Digital Victoria
org.opencontainers.image.authors=Victorian Department of Government Services
org.opencontainers.image.source=https://github.com/${{ github.repository }}/tree/${{ (contains(fromJson('["opened","synchronize"]'), github.event.action)) && github.head_ref || github.event.action == 'closed' && github.base_ref || github.ref_name }}/images/${{ matrix.images }}/Dockerfile
org.opencontainers.image.title=${{ matrix.images }}
org.opencontainers.image.description=${{ matrix.images }} image for Bay container platform
Expand All @@ -110,6 +107,7 @@ jobs:
uses: docker/bake-action@v5
with:
push: true
source: .
files: |
./gh-actions-bake.hcl
${{ steps.meta.outputs.bake-file }}
Expand Down
Loading