-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (145 loc) · 4.87 KB
/
build_all.yml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Build all
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- '**/README.md'
schedule:
# Every Saturday at 2AM UTC
- cron: "0 2 * * 6"
env:
DNF_CACHE_PATH: /var/cache/libdnf5 # F41+ and newer F40 with libdnf5
HOST_DNF_CACHE_PATH: /tmp/libdnf5 # Any path is okay
FEDORA_VERSION: "40"
jobs:
build-and-push:
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
id-token: write # needed for signing the images with GitHub OIDC Token
attestations: write
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Mkdir for DNF Cache
run: mkdir -p ${{ env.HOST_DNF_CACHE_PATH }}
- name: Restore DNF Cache
uses: actions/cache/restore@v4
with:
path: ${{ env.HOST_DNF_CACHE_PATH }}
key: dnf-cache
- name: Install Cosign
uses: sigstore/cosign-installer@v3.7.0
- name: Extract metadata for Docker (main)
id: meta-main
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
flavor: |
latest=true
tags: |
type=raw,value={{date 'YYYYMMDD'}}
- name: Extract metadata for Docker (minimal)
id: meta-minimal
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}-minimal
flavor: |
latest=true
tags: |
type=raw,value={{date 'YYYYMMDD'}}
- name: Log in to ghcr.io
uses: redhat-actions/podman-login@v1
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- name: Buildah Action (main)
id: build-image-main
uses: redhat-actions/buildah-build@v2
with:
context: fe
containerfiles: fe/Dockerfile.${{ env.FEDORA_VERSION }}
tags: ${{ steps.meta-main.outputs.tags }}
oci: true
extra-args: |
--squash
-v ${{ env.HOST_DNF_CACHE_PATH }}:${{ env.DNF_CACHE_PATH }}
- name: Buildah Action (minimal)
id: build-image-minimal
uses: redhat-actions/buildah-build@v2
with:
context: minimal
containerfiles: minimal/Dockerfile.${{ env.FEDORA_VERSION }}
tags: ${{ steps.meta-minimal.outputs.tags }}
oci: true
extra-args: |
--squash
-v ${{ env.HOST_DNF_CACHE_PATH }}:${{ env.DNF_CACHE_PATH }}
- name: Get Date for creating cache key
id: get-date
shell: bash
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
- name: Save DNF Cache
uses: actions/cache/save@v4
with:
path: ${{ env.HOST_DNF_CACHE_PATH }}
key: dnf-cache-${{ steps.get-date.outputs.date }}
- name: Push (main)
id: push-main
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image-main.outputs.image }}
tags: ${{ steps.build-image-main.outputs.tags }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
extra-args: |
--compression-format=zstd
- name: Push (minimal)
id: push-minimal
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image-minimal.outputs.image }}
tags: ${{ steps.build-image-minimal.outputs.tags }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
extra-args: |
--compression-format=zstd
- name: Sign the images with GitHub OIDC Token (main)
env:
DIGEST: ${{ steps.push-main.outputs.digest }}
TAGS: ${{ steps.meta-main.outputs.tags }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}
- name: Sign the images with GitHub OIDC Token (minimal)
env:
DIGEST: ${{ steps.push-minimal.outputs.digest }}
TAGS: ${{ steps.meta-minimal.outputs.tags }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}
- name: Attest (main)
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.push-main.outputs.digest }}
push-to-registry: true
- name: Attest (minimal)
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/${{ github.repository }}-minimal
subject-digest: ${{ steps.push-minimal.outputs.digest }}
push-to-registry: true