Skip to content

Commit 5fb0e8f

Browse files
committed
cicd: prepare workflow for release
1 parent 23cb2d2 commit 5fb0e8f

File tree

2 files changed

+71
-21
lines changed

2 files changed

+71
-21
lines changed

.github/workflows/docker-matrix-wheels.yml

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
uses: docker/setup-buildx-action@v2
3636
with:
3737
driver-opts: |
38-
image=moby/buildkit:v0.10.6
38+
image=moby/buildkit:v0.12.4
3939
4040
4141
- name: Build builder stage
@@ -81,6 +81,11 @@ jobs:
8181
for i in "${MODS[@]}"
8282
do
8383
REQS=$(jq -cr 'select(.requirements != []).requirements' ./"$i"/manifest.json)
84+
## Just for testing the pipeline with a subset of modules
85+
if ! [[ "$i" =~ ^(googlecast|geizhals|fhem_forum|bt_presence)$ ]]; then
86+
continue
87+
fi
88+
## End of test
8489
if [[ -z $REQS ]]; then
8590
continue
8691
fi
@@ -187,17 +192,6 @@ jobs:
187192
run: |
188193
./scripts/test-integration.sh ${{ steps.build-it.outputs.imageid }}
189194
190-
- name: Find image String
191-
id: extract_image
192-
run: |
193-
echo "image_name=$(grep -m 1 '^FROM' Dockerfile | cut -d ' ' -f2 | cut -d ':' -f1)" >> $GITHUB_OUTPUT
194-
echo "image_version=$(grep -m 1 '^FROM' Dockerfile | cut -d ' ' -f2 | cut -d ':' -f2)" >> $GITHUB_OUTPUT
195-
196-
- name: Update docs
197-
if: ${{ github.event_name == 'release' }}
198-
run: |
199-
sed -e "s/{FHEMPY_VERSION}/${{ needs.prepare_build.outputs.fhempyV }}/" -e "s/{PYTHON_VERSION}/${{ steps.extract_image.outputs.image_version}}/" -e "s/{DEBIAN_RELEASE}/buster/" -e s/{IMAGE_TAG}/${{ github.ref_name }}/ < README.tmpl > README.md
200-
201195
- name: Install cosign
202196
if: github.event_name == 'release'
203197
uses: sigstore/cosign-installer@v2.8.1
@@ -227,6 +221,8 @@ jobs:
227221
type=semver,pattern={{major}},enable=${{ github.event.release.prerelease == 0 }}
228222
type=ref,event=branch
229223
type=ref,event=pr
224+
labels: |
225+
org.opencontainers.image.title=${{ env.IMAGE_NAME }}_${{ matrix.module }}
230226
231227
- name: Build and push Docker image for all plattforms
232228
uses: docker/build-push-action@v3.2.0
@@ -238,7 +234,7 @@ jobs:
238234
tags: ${{ steps.meta.outputs.tags }}
239235
labels: ${{ steps.meta.outputs.labels }}
240236
target: runtime
241-
cache-to: type=gha,scope=runtime-stage_cross-${{ matrix.module }}_${{ hashFiles('./requirements_mod.txt') }}
237+
cache-to: type=gha,scope=runtime-stage_cross-${{ matrix.module }}_${{ hashFiles('./requirements_mod.txt') }},mode=max
242238
cache-from: |
243239
type=gha,scope=base_stage_cross
244240
type=gha,scope=runtime-stage_cross
@@ -248,8 +244,9 @@ jobs:
248244
249245
- name: show image details
250246
run: |
251-
echo ${{ steps.docker_build_runtime_cross.outputs.imageid }}
252-
echo ${{ steps.docker_build_runtime_cross.outputs.digest }}
247+
echo "${{ steps.docker_build_runtime_cross.outputs.imageid }}"
248+
echo "${{ steps.docker_build_runtime_cross.outputs.digest }}"
249+
echo "${{ steps.docker_build_runtime_cross.outputs.metadata }}"
253250
# Sign the resulting Docker image digest except on PRs.
254251
# This will only write to the public Rekor transparency log when the Docker
255252
# repository is public to avoid leaking data. If you would like to publish
@@ -262,7 +259,50 @@ jobs:
262259
# This step uses the identity token to provision an ephemeral certificate
263260
# against the sigstore community Fulcio instance.
264261
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.docker_build_runtime_cross.outputs.digest }}
262+
263+
- name: Create Job Summary
264+
run: |
265+
echo "### Image report for : ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
266+
echo "| Module | Image name |" >> $GITHUB_STEP_SUMMARY
267+
echo "|-------|----------------------------------------------------------------------|" >> $GITHUB_STEP_SUMMARY
268+
echo "| ${{ matrix.module }} | ${{ fromJSON(steps.docker_build_runtime_cross.outputs.metadata)['image.name'] }} |" >> $GITHUB_STEP_SUMMARY
269+
echo "| ${{ matrix.module }} | ${{ fromJSON(steps.docker_build_runtime_cross.outputs.metadata)['image.name'] }} |" > matrix_result.md
265270
271+
- name: Upload artifact
272+
uses: actions/upload-artifact@v3
273+
with:
274+
name: ${{ hashFiles('matrix_result.md') || 'none' }}
275+
path: matrix_result.md
276+
if-no-files-found: warn
277+
278+
check-matrix:
279+
runs-on: ubuntu-latest
280+
needs: [buildImages,prepare_build]
281+
permissions:
282+
contents: write
283+
steps:
284+
- name: Checkout repository
285+
uses: actions/checkout@v3
286+
287+
- uses: actions/download-artifact@v3
288+
289+
- name: Find image String
290+
id: extract_image
291+
run: |
292+
echo "image_name=$(grep -m 1 '^FROM' Dockerfile | cut -d ' ' -f2 | cut -d ':' -f1)" >> $GITHUB_OUTPUT
293+
echo "image_version=$(grep -m 1 '^FROM' Dockerfile | cut -d ' ' -f2 | cut -d ':' -f2)" >> $GITHUB_OUTPUT
294+
295+
- name: Update docs (readme.md)
296+
run: |
297+
cat */matrix_result.md > modules.md
298+
IMAGE_LIST=$(cat modules.md)
299+
echo "$IMAGE_LIST"
300+
ESCAPED_DATA="$(echo "${IMAGE_LIST}" | sed 's/\n/\\n/g')"
301+
echo "--------"
302+
echo "$ESCAPED_DATA"
303+
sed -e "s/{FHEMPY_VERSION}/${{ needs.prepare_build.outputs.fhempyV }}/" -e "s/{PYTHON_VERSION}/${{ steps.extract_image.outputs.image_version}}/" -e "s/{DEBIAN_RELEASE}/buster/" -e s,{IMAGE_TAG},${{ github.ref_name }}, < README.tmpl > README.md
304+
sed -i -e "/{MODULES_IMAGE_LIST}/r modules.md" -e "/{MODULES_IMAGE_LIST}/d" README.md
305+
266306
- name: git commit README.md
267307
id: commit
268308
if: ${{ github.event_name == 'release' }}
@@ -277,4 +317,7 @@ jobs:
277317
with:
278318
token: ${{ secrets.BOT_PUSH_TOKEN }}
279319
branch: main
280-
#unprotect_reviews: true
320+
321+
- name: Set step summary
322+
run: |
323+
cat README.md >> $GITHUB_STEP_SUMMARY

README.tmpl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# fhempy-docker
2-
Docker Container with [fhempy](https://github.com/fhempy/fhempy) which can be connected to [FHEM](https://fhem.de/)
2+
Docker Containers with [fhempy](https://github.com/fhempy/fhempy) which can be connected to [FHEM](https://fhem.de/)
3+
4+
# Every image comes as a seperate image.
5+
If you want two modules, you have to start two containers.
36

4-
# Image with Perl core modules installed
57

68
* Debian 11 {DEBIAN_RELEASE}
79
* Python {PYTHON_VERSION}
810
* fhempy {FHEMPY_VERSION}
911

1012

11-
1213
# How to use with docker-compose
1314

1415
Running fhempy in a docker environment is done by starting the container and connect it within the same network as your fhem container:
@@ -18,9 +19,15 @@ Example is assuming, that your FHEM network is named `net` and already defined a
1819
fhempy:
1920
networks:
2021
- net
21-
image: ghcr.io/fhem/fhempy-docker:{IMAGE_TAG}
22+
image: ghcr.io/fhem/fhempy-docker-<modulename>:{IMAGE_TAG}
2223
```
2324

2425
To start your container right away:
2526

26-
docker run -d --name fhempy ghcr.io/fhem/fhempy-docker:{IMAGE_TAG}
27+
docker run -d --name fhempy ghcr.io/fhem/fhempy-docker-<modulename>:{IMAGE_TAG}
28+
29+
30+
# Supported Modules and their image
31+
32+
| Module | Image name |
33+
{MODULES_IMAGE_LIST}

0 commit comments

Comments
 (0)