-
-
Notifications
You must be signed in to change notification settings - Fork 4
134 lines (123 loc) · 3.82 KB
/
release.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: "Docker: Build and Push"
on:
workflow_dispatch:
push:
branches:
- main
paths:
- apps/**
- .github/workflows/release.yaml
- .github/workflows/workflow_call-build_image.yaml
pull_request:
paths:
- apps/**
- .github/workflows/release.yaml
- .github/workflows/workflow_call-build_image.yaml
types:
- opened
- synchronize
- reopened
jobs:
get-changed-images:
name: Determine changed images
runs-on: ubuntu-latest
outputs:
changed_images: ${{ steps.filter-containers.outputs.all_changed_files }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Determine changed images
uses: tj-actions/changed-files@v45
id: filter-containers
with:
dir_names: true
dir_names_max_depth: "1"
path: apps
separator: ","
- name: Add summary
env:
CHANGED_IMAGES: "${{ steps.filter-containers.outputs.all_changed_files }}"
run: |
IFS=',' read -r -a images <<< "${CHANGED_IMAGES}"
echo "### Changed images:" > "$GITHUB_STEP_SUMMARY"
for image in "${images[@]}"; do
echo "- ${image}" >> "$GITHUB_STEP_SUMMARY"
done
generate-matrix:
name: Generate build matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
needs:
- get-changed-images
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"
- name: Install dependencies
run: npm install
- name: Generate matrix
run: npm run genmatrix
env:
DEFAULT_SOURCE_URL: "https://github.com/${{ github.repository }}"
IMAGES_FOLDER: "apps"
INCLUDE_IMAGES: ${{ needs.get-changed-images.outputs.changed_images }}
- name: Save Matrix
id: matrix
run: |
matrix="$(cat matrix.json)"
echo "matrix=${matrix}" >> "$GITHUB_OUTPUT"
build:
name: Build ${{ matrix.job_name }} image
needs:
- generate-matrix
strategy:
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
fail-fast: false
uses: ./.github/workflows/workflow_call-build_image.yaml
with:
app: ${{ matrix.job_name }}
image: |
ghcr.io/bjw-s-labs/${{ matrix.job_name }}
ghcr.io/bjw-s/${{ matrix.job_name }}
platforms: |
${{ join(matrix.platforms, ', ') }}
tags: |
type=raw,value=${{ matrix.targetVersion }}
type=raw,value=latest
type=semver,pattern={{major}}.{{minor}},value=${{ matrix.targetVersion }}
type=semver,pattern={{major}},value=${{ matrix.targetVersion }}
build-args: |
VERSION=${{ matrix.sourceVersion }}
context: ${{ matrix.context }}
dockerfile: ${{ matrix.dockerfile }}
labels: |
org.opencontainers.image.title=${{ matrix.job_name }}
org.opencontainers.image.source=${{ matrix.source_repo }}
annotations: |
org.opencontainers.image.title=${{ matrix.job_name }}
org.opencontainers.image.source=${{ matrix.source_repo }}
dry-run: ${{ github.ref != 'refs/heads/main' || github.event_name == 'pull_request' }}
type: ${{ matrix.type }}
tests-enabled: ${{ matrix.tests.enabled }}
secrets:
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
build_success:
name: Build matrix success
needs:
- build
if: |
always()
runs-on: ubuntu-latest
steps:
- name: Check matrix status
if: >-
${{
(contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled'))
}}
run: exit 1