Skip to content

Commit

Permalink
ci: run docker build on push to master
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantk committed Feb 2, 2024
1 parent aadf13c commit 8747119
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build-and-push-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and push docker image

on:
workflow_dispatch:
workflow_call:
push:
branches:
- master

jobs:
build_and_push_docker_image:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3.3.0

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Determine tag
id: determine_tag
run: |
base_image="ghcr.io/dfe-digital/buying-for-schools-admin"
branch="${{ github.ref_name }}"
commit="$(echo $GITHUB_SHA | head -c7)"
if [ "$branch" == "master" ]; then
echo tags=${base_image}:${commit},${base_image}:latest >> $GITHUB_OUTPUT
else
echo tags=${base_image}:${commit},${base_image}:${branch} >> $GITHUB_OUTPUT
fi
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.determine_tag.outputs.tags }}



0 comments on commit 8747119

Please sign in to comment.