-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (49 loc) · 1.58 KB
/
build-images.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
53
54
55
56
name: build-images
on:
push:
jobs:
list:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- id: set-matrix
run: |
echo "matrix=$(find images -type f -name 'Dockerfile.*' | awk -F'.' '{print $2}' | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
push-ghcr:
needs: list
name: Build and push image
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
id-token: write
strategy:
fail-fast: false
matrix:
chal: ${{ fromJson(needs.list.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Generate variables
id: vars
run: |
echo "date=$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT
- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build image
run: |
docker build \
--tag ghcr.io/${{ github.repository_owner }}/tag-${{ matrix.chal }}:${{ steps.vars.outputs.date }} \
--tag ghcr.io/${{ github.repository_owner }}/tag-${{ matrix.chal }}:latest \
--file images/Dockerfile.${{ matrix.chal }} \
images
- name: Push to ghcr
run: |
docker push ghcr.io/${{ github.repository_owner }}/tag-${{ matrix.chal }}:${{ steps.vars.outputs.date }}
docker push ghcr.io/${{ github.repository_owner }}/tag-${{ matrix.chal }}:latest