1
+ name : Docker test
2
+ on :
3
+ push :
4
+
5
+ jobs :
6
+ docker :
7
+ permissions :
8
+ contents : read
9
+ packages : write
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - name : Checkout code
13
+ uses : actions/checkout@v4
14
+
15
+ - name : Set up QEMU
16
+ uses : docker/setup-qemu-action@v3
17
+
18
+ - name : Set up Docker Buildx
19
+ uses : docker/setup-buildx-action@v3
20
+
21
+ - name : Cache docker layers
22
+ if : ${{ !env.ACT }}
23
+ uses : actions/cache@v4
24
+ id : cache
25
+ with :
26
+ path : /tmp/.buildx-cache
27
+ key : ${{ runner.os }}-buildx-${{ matrix.service }}-${{ github.sha }}
28
+ restore-keys : |
29
+ ${{ runner.os }}-buildx-${{ matrix.service }}
30
+ ${{ runner.os }}-buildx-
31
+
32
+ - name : Docker meta
33
+ id : meta
34
+ uses : docker/metadata-action@v5
35
+ with :
36
+ # list of Docker images to use as base name for tags
37
+ images : |
38
+ mcuadros/ofelia
39
+ ghcr.io/${{ github.repository }}
40
+ flavor : |
41
+ latest=false
42
+ tags : |
43
+ type=raw,value=development,enable=${{ github.event_name != 'release' }}
44
+ type=raw,value=latest,enable=${{ github.event_name == 'release' }}
45
+ type=semver,pattern={{version}}
46
+ type=semver,pattern={{major}}.{{minor}}
47
+ type=sha,enable=true,priority=100,prefix=,suffix=,format=short
48
+
49
+ - name : Print
50
+ run : echo ${{ steps.meta.outputs.bake-file }}
51
+
52
+ - name : Prepare version number
53
+ id : prepare
54
+ run : |
55
+ VERSION=$(git describe --always --tags)
56
+ if [ "${{ github.event_name }}" = "release" ]; then
57
+ TAGS="mcuadros/ofelia:$VERSION,mcuadros/ofelia:latest"
58
+ # Replace with below once @mcuadros adds the DOCKER_USERNAME secret
59
+ #TAGS="${{secrets.DOCKER_USERNAME}}/ofelia:$VERSION,${{secrets.DOCKER_USERNAME}}/ofelia:latest"
60
+ else
61
+ TAGS="mcuadros/ofelia:$VERSION,mcuadros/ofelia:development"
62
+ # Replace with below once @mcuadros adds the DOCKER_USERNAME secret
63
+ #TAGS="${{secrets.DOCKER_USERNAME}}/ofelia:$VERSION,${{secrets.DOCKER_USERNAME}}/ofelia:development"
64
+ fi
65
+ echo ::set-output name=tags::${TAGS}
66
+
67
+
68
+ - name : Print
69
+ run : echo ${{ steps.meta.outputs.tags }}
70
+
71
+ - name : Login to DockerHub
72
+ uses : docker/login-action@v3
73
+ with :
74
+ username : mcuadros
75
+ # Replace with below once @mcuadros adds the DOCKER_USERNAME secret
76
+ # username: ${{ secrets.DOCKER_USERNAME }}
77
+ password : ${{ secrets.DOCKER_PASSWORD }}
78
+
79
+
80
+ - name : Login to GHCR
81
+ uses : docker/login-action@v3
82
+ with :
83
+ registry : ghcr.io
84
+ username : ${{ github.actor }}
85
+ password : ${{ secrets.GITHUB_TOKEN }}
0 commit comments