-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (44 loc) · 1.24 KB
/
build-test-push.yaml
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, test and push image
on:
push:
workflow_dispatch:
jobs:
build-test-push:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Build image
run: |
docker buildx build \
--output=type=docker \
--cache-to type=gha,mode=max \
--cache-from type=gha \
--load \
--progress=plain \
--iidfile=iid \
.
- name: Run tests
run: |
docker run --rm $(<iid) test
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Tag and push image
run: |
docker tag $(<iid) rootmos/silly-k:$GITHUB_SHA
docker push rootmos/silly-k:$GITHUB_SHA
- name: Mark as latest image
if: github.ref_name == 'master'
run: |
docker tag $(<iid) rootmos/silly-k:latest
docker push rootmos/silly-k:latest