-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (47 loc) · 1.52 KB
/
build-on-commit.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
46
47
48
49
50
51
52
name: Build On Commit
on:
push:
branches:
- master
- develop
jobs:
e2e-tests:
uses: ./.github/workflows/e2e-tests.yml
publish:
name: Push image to Docker Hub
runs-on: ubuntu-latest
needs: e2e-tests
steps:
- name: Extract branch name
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
id: branch
- name: Derive docker hub repo name
id: repo_name
shell: bash
run: |
REGEX="/ab_service_(.+)"
[[ "${{ github.repository }}" =~ $REGEX ]]
DOCKER_HUB_REPO=ab-${BASH_REMATCH[1]/_/-}
echo "docker_hub_repo=$DOCKER_HUB_REPO" >> $GITHUB_OUTPUT
- name: Get commit sha
id: sha
run: echo "short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
- name: Check out the git repo
uses: actions/checkout@v3
with:
submodules: recursive
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push to Docker Hub
uses: docker/build-push-action@v4
with:
context: .
push: true
build-args: BRANCH=${{ steps.branch.outputs.branch }}
tags: |
digiserve/${{ steps.repo_name.outputs.docker_hub_repo }}:${{ steps.branch.outputs.branch }}
digiserve/${{ steps.repo_name.outputs.docker_hub_repo }}:${{ steps.sha.outputs.short }}