Build and push docker image #8
Workflow file for this run
This file contains 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: 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/[email protected] | |
- 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-v2" | |
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 }} | |