Skip to content

Commit

Permalink
Merge pull request #1215 from alphagov/add-build-image-on-tags-GitHub…
Browse files Browse the repository at this point in the history
…-action

Add build-image-on-tags GitHub action
  • Loading branch information
nimalank7 authored Nov 22, 2023
2 parents 388228a + ed9471b commit 8dc9141
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build-image-on-tags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build and push images on tags

on:
push:
tags:
- 'k[0-9]+.[0-9]+.[0-9]+'

jobs:
build_and_push:
name: datagovuk-publish
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Login to GHCR
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
ref: ${{ inputs.gitRef }}
- name: Build and push images
env:
APP: datagovuk_publish
ARCH: amd64
GH_REF: ${{ github.ref_name }}
run: ./docker/build-image.sh
4 changes: 4 additions & 0 deletions docker/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ build () {

DOCKER_TAG="${GITHUB_SHA}"

if [[ -n ${GH_REF:-} ]]; then
DOCKER_TAG="${GH_REF}"
fi

build "${DOCKER_TAG}"

if [[ -n ${DRY_RUN:-} ]]; then
Expand Down

0 comments on commit 8dc9141

Please sign in to comment.