-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (37 loc) · 1.17 KB
/
build image.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
name: Build Docker image
on:
push:
workflow_dispatch:
env:
registry: ghcr.io
jobs:
Build_image:
runs-on: ubuntu-latest
permissions:
packages: write
strategy:
matrix:
distro:
- Alpine
- Debian
steps:
- uses: actions/checkout@v3
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Declare image name
run: image=${GITHUB_REPOSITORY,,} && <<<image=${image%-*} tee -a "$GITHUB_ENV"
- name: Build Docker image (${{ matrix.distro }})
run: docker build --tag ${tag=${{ env.registry }}/${{ env.image }}:${distro,,}} - <$distro.Dockerfile
&& <<<tag=$tag tee -a "$GITHUB_ENV"
env:
distro: ${{ matrix.distro }}
- name: Push Docker image (${{ env.tag }})
run: docker push ${{ env.tag }}
- name: Push "latest" tag
run: docker tag "$tag" ${latest=${{ env.registry }}/${{ env.image }}}
&& docker push "$latest"
if: ${{ matrix.distro == 'Alpine' }}