-
-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (68 loc) · 2.21 KB
/
publish.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
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build & publish container images
on:
workflow_dispatch: {}
# push:
# branches:
# - main
jobs:
find-changed-images:
runs-on: ubuntu-latest
outputs:
apps: ${{ steps.set-matrix.outputs.apps }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Collect changed files
uses: dorny/paths-filter@v3
id: filter
with:
base: 'main'
list-files: json
filters: |
changed:
- added|deleted|modified: 'apps/*/**'
- name: Set apps Matrix
if: ${{ steps.filter.outputs.changed == 'true' }}
id: set-matrix
run: |
PATHS='${{ steps.filter.outputs.changed_files }}'
DATA=$(echo $PATHS | jq -c '. | map(split("/")[1]) | unique')
echo "apps=$DATA" >> "$GITHUB_OUTPUT"
build-and-publish-changed-images:
needs: find-changed-images
if: ${{ needs.find-changed-images.outputs.apps != '' && toJson(fromJson(needs.find-changed-images.outputs.apps)) != '[]' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
app: ${{ fromJSON(needs.find-changed-images.outputs.apps) }}
steps:
- name: Lowercase repository owner
shell: bash
run: echo "LOWERCASE_REPO_OWNER=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Container meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ env.LOWERCASE_REPO_OWNER }}/${{ matrix.app }}
tags: |
type=sha, format=long
- name: Build and push to ghcr
uses: docker/build-push-action@v6
with:
context: .
file: 'apps/${{ matrix.app }}/Dockerfile'
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}