-
Notifications
You must be signed in to change notification settings - Fork 1
184 lines (168 loc) · 7.26 KB
/
ci.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: ci
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
# Job to run change detection
changes:
runs-on: ubuntu-latest
outputs:
# Expose matched filters as job 'images' output variable
images: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
# Use context to get the branch where commits were pushed.
# If there is only one long-lived branch (e.g. master),
# you can specify it directly.
# If it's not configured, the repository default branch is used.
base: ${{ github.ref }}
filters: |
aws-cli: 'aws-cli/**'
black: 'black/**'
bootstrap/cinc-auditor: 'bootstrap/cinc-auditor/**'
bootstrap/dasel: 'bootstrap/dasel/**'
bootstrap/hadolint: 'bootstrap/hadolint/**'
buildpack-deps/ubuntu/jammy/curl: 'buildpack-deps/ubuntu/jammy/curl/**'
buildpack-deps/ubuntu/jammy/scm: 'buildpack-deps/ubuntu/jammy/scm/**'
buildpack-deps/ubuntu/jammy: 'buildpack-deps/ubuntu/jammy/*'
cinc/cinc: 'cinc/cinc/**'
cinc/cinc-workstation: 'cinc/cinc-workstation/**'
doctl: 'doctl/**'
dokken/almalinux-8: 'dokken/almalinux-8/**'
dokken/almalinux-9: 'dokken/almalinux-9/**'
dokken/amazonlinux-2: 'dokken/amazonlinux-2/**'
dokken/amazonlinux-2022: 'dokken/amazonlinux-2022/**'
dokken/centos-stream-8: 'dokken/centos-stream-8/**'
dokken/centos-stream-9: 'dokken/centos-stream-9/**'
dokken/debian-11: 'dokken/debian-11/**'
dokken/debian-12: 'dokken/debian-12/**'
dokken/opensuse-leap-15.3: 'dokken/opensuse-leap-15.3/**'
dokken/opensuse-leap-15.4: 'dokken/opensuse-leap-15.4/**'
dokken/oraclelinux-8: 'dokken/oraclelinux-8/**'
dokken/oraclelinux-9: 'dokken/oraclelinux-9/**'
dokken/rockylinux-8: 'dokken/rockylinux-8/**'
dokken/rockylinux-9: 'dokken/rockylinux-9/**'
dokken/ubuntu-20.04: 'dokken/ubuntu-20.04/**'
dokken/ubuntu-22.04: 'dokken/ubuntu-22.04/**'
flake8: 'flake8/**'
glab: 'glab/**'
grafana/grafana-oss: 'grafana/grafana-oss/**'
hashicorp/terraform: 'hashicorp/terraform/**'
letsencrypt/certbot: 'letsencrypt/certbot/**'
letsencrypt/certbot-dns-cloudflare: 'letsencrypt/certbot-dns-cloudflare/**'
markdownlint: 'markdownlint/**'
meshcmd: 'meshcmd/**'
node/18/jammy: 'node/18/jammy/**'
op: 'op/**'
paperspace-cli: 'paperspace-cli/**'
portainer-ce: 'portainer-ce/**'
postgres/15/focal: 'postgres/15/focal/**'
prometheus/alertmanager: 'prometheus/alertmanager/**'
prometheus/blackbox_exporter: 'prometheus/blackbox_exporter/**'
prometheus/collectd_exporter: 'prometheus/collectd_exporter/**'
prometheus/node_exporter: 'prometheus/node_exporter/**'
prometheus/prometheus: 'prometheus/prometheus/**'
pspace: 'pspace/**'
pulumi/pulumi-base: 'pulumi/pulumi-base/**'
pulumi/pulumi-python: 'pulumi/pulumi-python/**'
python/3.8/focal: 'python/3.8/focal/**'
python/3.8/jammy: 'python/3.8/jammy/**'
ruby/3.1/jammy: 'ruby/3.1/jammy/**'
ruby/3.1/slim-jammy: 'ruby/3.1/slim-jammy/**'
rust/1.64.0/focal: 'rust/1.64.0/focal/*'
rust/1.64.0/focal/slim: 'rust/1.64.0/focal/slim/**'
shellcheck: 'shellcheck/**'
smokeping: 'smokeping/**'
# Job to build and test each of the modified images
build:
needs: changes
strategy:
matrix:
# Parse JSON array containing names of all filters matching any of changed files
# e.g. ['image1', 'image2'] if both image folders contains changes
image: ${{ fromJSON(needs.changes.outputs.images) }}
if: ${{ needs.changes.outputs.images != '[]' && needs.changes.outputs.images != '' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ matrix.image }}
steps:
- uses: actions/checkout@v3
- name: Check the Containerfile with hadolint
run: |
$(git rev-parse --show-toplevel)/bin/lint.sh
- name: Install QEMU static binaries
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Set the tags
id: tags
run: |
echo "tags=$($(git rev-parse --show-toplevel)/bin/list-tags.sh -c)" >> $GITHUB_ENV
- name: Build locally for testing
uses: docker/build-push-action@v4
with:
load: true
context: ${{ matrix.image }}
file: ${{ matrix.image }}/Containerfile
tags: ${{ env.tags }}
- name: Run tests on the cinc/cinc image with cinc-auditor
if: matrix.image == 'cinc/cinc'
run: |
$(git rev-parse --show-toplevel)/bin/test.sh "$( $(git rev-parse --show-toplevel)/bin/list-tags.sh | head -n 1 )" "/bin/sh"
- name: Run tests on the image with cinc-auditor
if: matrix.image != 'cinc/cinc'
run: |
$(git rev-parse --show-toplevel)/bin/test.sh
- name: Set the platforms
if: github.event_name == 'push'
id: platforms
run: |
echo "platforms=$($(git rev-parse --show-toplevel)/bin/list-platforms.sh -c)" >> $GITHUB_ENV
- name: Login to DockerHub
if: github.event_name == 'push'
uses: docker/login-action@v2
with:
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
password: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
- name: Build and push
if: github.event_name == 'push'
uses: docker/build-push-action@v4
with:
push: true
context: ${{ matrix.image }}
file: ${{ matrix.image }}/Containerfile
platforms: ${{ env.platforms }}
tags: ${{ env.tags }}
env:
BUILDKIT_PROGRESS: plain
- name: Set the image name
if: github.event_name == 'push'
id: image_name
run: |
echo "image_name=$($(git rev-parse --show-toplevel)/bin/image-name.sh)" >> $GITHUB_ENV
- name: Set the image description
if: github.event_name == 'push'
id: image_description
run: |
echo "image_description=$($(git rev-parse --show-toplevel)/bin/image-description.sh)" >> $GITHUB_ENV
- name: Set the image readme
if: github.event_name == 'push'
id: image_readme
run: |
echo "image_readme=$($(git rev-parse --show-toplevel)/bin/image-readme.sh)" >> $GITHUB_ENV
- name: Update Docker Hub Description
if: github.event_name == 'push'
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
password: ${{ secrets.CONTAINER_DESCRIPTION_PASSWORD }}
short-description: ${{ env.image_description }}
repository: polymathrobotics/${{ env.image_name }}
readme-filepath: ${{ env.image_readme }}