-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathdocker.yaml
More file actions
80 lines (74 loc) · 2.68 KB
/
Copy pathdocker.yaml
File metadata and controls
80 lines (74 loc) · 2.68 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Docker
on:
release:
types: [published]
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
changed_agencies: ${{ steps.detect-changes.outputs.changed_agencies }}
has_changes: ${{ steps.detect-changes.outputs.has_changes }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed agencies
id: detect-changes
run: |
# Make the script executable
chmod +x ./bin/detect-changed-agencies.sh
# Get changed agencies as JSON
CHANGED_AGENCIES=$(./bin/detect-changed-agencies.sh --current-tag ${{ github.ref_name }} --json)
echo "Detected changes: $CHANGED_AGENCIES"
# Set the matrix output
echo "changed_agencies=$CHANGED_AGENCIES" >> $GITHUB_OUTPUT
# Check if we have any changes (empty array is "[]")
if [ "$CHANGED_AGENCIES" != "[]" ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
buildx:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.has_changes == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
agency: ${{ fromJson(needs.detect-changes.outputs.changed_agencies) }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.agency }}
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push images
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
file: Dockerfile.${{ matrix.agency }}
push: true
tags: |
ghcr.io/${{ github.repository }}-${{ matrix.agency }}:latest
ghcr.io/${{ github.repository }}-${{ matrix.agency }}:${{ github.ref_name }}