-
Notifications
You must be signed in to change notification settings - Fork 2
48 lines (38 loc) · 1.17 KB
/
build-and-push-docker-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 }}