-
Notifications
You must be signed in to change notification settings - Fork 13
76 lines (71 loc) · 2.54 KB
/
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
name: build-images
permissions:
contents: read
on:
pull_request:
branches:
- main
push:
branches:
- main
schedule:
- cron: "0 0 * * *"
env:
REGISTRY: ghcr.io
jobs:
list:
runs-on: ubuntu-latest
outputs:
images: ${{ steps.output-images.outputs.images }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: list images
id: output-images
run: |
echo "images=$(ls images | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: list
strategy:
matrix:
image: ${{fromJSON(needs.list.outputs.images)}}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 2
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@4edd678ac3f81e2dc578756871e4d00c19191daf # v45.0.4
with:
files: |
images/${{ matrix.image }}/**
- name: changed files
if: steps.changed-files.outputs.any_changed == 'true'
run: |
echo ${{ steps.changed-files.outputs.any_changed }}
echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}"
- name: Log in to the Container registry
if: steps.changed-files.outputs.any_changed == 'true' || github.event_name != 'pull_request'
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # 343f7c4344506bcbf9b4de18042ae17996df046d
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
if: steps.changed-files.outputs.any_changed == 'true' || github.event_name != 'pull_request'
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.image }}
- name: Build and push Docker image
if: steps.changed-files.outputs.any_changed == 'true' || github.event_name != 'pull_request'
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v5
with:
context: images/${{ matrix.image }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}