Skip to content

Commit

Permalink
cicd: prepare workflow for release
Browse files Browse the repository at this point in the history
  • Loading branch information
sidey79 committed Dec 5, 2023
1 parent 23cb2d2 commit f61cb2f
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 20 deletions.
66 changes: 51 additions & 15 deletions .github/workflows/docker-matrix-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: docker/setup-buildx-action@v2
with:
driver-opts: |
image=moby/buildkit:v0.10.6
image=moby/buildkit:v0.12.4
- name: Build builder stage
Expand Down Expand Up @@ -81,6 +81,11 @@ jobs:
for i in "${MODS[@]}"
do
REQS=$(jq -cr 'select(.requirements != []).requirements' ./"$i"/manifest.json)
## Just for testing the pipeline with a subset of modules
if ! [[ "$i" =~ ^(googlecast|geizhals|fhem_forum|bt_presence)$ ]]; then
continue
fi
## End of test
if [[ -z $REQS ]]; then
continue
fi
Expand Down Expand Up @@ -187,17 +192,6 @@ jobs:
run: |
./scripts/test-integration.sh ${{ steps.build-it.outputs.imageid }}
- name: Find image String
id: extract_image
run: |
echo "image_name=$(grep -m 1 '^FROM' Dockerfile | cut -d ' ' -f2 | cut -d ':' -f1)" >> $GITHUB_OUTPUT
echo "image_version=$(grep -m 1 '^FROM' Dockerfile | cut -d ' ' -f2 | cut -d ':' -f2)" >> $GITHUB_OUTPUT
- name: Update docs
if: ${{ github.event_name == 'release' }}
run: |
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
- name: Install cosign
if: github.event_name == 'release'
uses: sigstore/[email protected]
Expand Down Expand Up @@ -227,18 +221,20 @@ jobs:
type=semver,pattern={{major}},enable=${{ github.event.release.prerelease == 0 }}
type=ref,event=branch
type=ref,event=pr
labels: |
org.opencontainers.image.title=${{ env.IMAGE_NAME }}_${{ matrix.module }}
- name: Build and push Docker image for all plattforms
uses: docker/[email protected]
id: docker_build_runtime_cross
with:
context: .
platforms: linux/arm/v7,linux/amd64
push: true # ${{ github.event_name == 'release' }}
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: runtime
cache-to: type=gha,scope=runtime-stage_cross-${{ matrix.module }}_${{ hashFiles('./requirements_mod.txt') }}
cache-to: type=gha,scope=runtime-stage_cross-${{ matrix.module }}_${{ hashFiles('./requirements_mod.txt') }},mode=max
cache-from: |
type=gha,scope=base_stage_cross
type=gha,scope=runtime-stage_cross
Expand All @@ -262,7 +258,44 @@ jobs:
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.docker_build_runtime_cross.outputs.digest }}

- name: Create Job Summary
run: |
echo "### Size report for commit: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "| Module | Image name |" >> $GITHUB_STEP_SUMMARY
echo "|-------|----------------------------------------------------------------------|" >> $GITHUB_STEP_SUMMARY
echo "| ${{ matrix.module }} | ${{ fromJSON(steps.docker_build_runtime_cross.outputs.metadata)['image.name'] }} |" >> $GITHUB_STEP_SUMMARY
echo "| ${{ matrix.module }} | ${{ fromJSON(steps.docker_build_runtime_cross.outputs.metadata)['image.name'] }} |" > matrix_result.md
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ hashFiles('matrix_result.md') || 'none' }}
path: matrix_result.md
if-no-files-found: warn

check-matrix:
runs-on: ubuntu-latest
needs: [buildImages,prepare_build]
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3

- uses: actions/download-artifact@v3

- name: Find image String
id: extract_image
run: |
echo "image_name=$(grep -m 1 '^FROM' Dockerfile | cut -d ' ' -f2 | cut -d ':' -f1)" >> $GITHUB_OUTPUT
echo "image_version=$(grep -m 1 '^FROM' Dockerfile | cut -d ' ' -f2 | cut -d ':' -f2)" >> $GITHUB_OUTPUT
- name: Update docs (readme.md)
run: |
IMAGE_LIST="$(cat */matrix_result.md )"
sed -e "s/{MODULES_IMAGE_LIST}/$IMAGE_LIST/" -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
- name: git commit README.md
id: commit
if: ${{ github.event_name == 'release' }}
Expand All @@ -277,4 +310,7 @@ jobs:
with:
token: ${{ secrets.BOT_PUSH_TOKEN }}
branch: main
#unprotect_reviews: true

- name: Set step summary
run: |
cat README.md >> $GITHUB_STEP_SUMMARY
17 changes: 12 additions & 5 deletions README.tmpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# fhempy-docker
Docker Container with [fhempy](https://github.com/fhempy/fhempy) which can be connected to [FHEM](https://fhem.de/)
Docker Containers with [fhempy](https://github.com/fhempy/fhempy) which can be connected to [FHEM](https://fhem.de/)

# Every image comes as a seperate image.
If you want two modules, you have to start two containers.

# Image with Perl core modules installed

* Debian 11 {DEBIAN_RELEASE}
* Python {PYTHON_VERSION}
* fhempy {FHEMPY_VERSION}



# How to use with docker-compose

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

To start your container right away:

docker run -d --name fhempy ghcr.io/fhem/fhempy-docker:{IMAGE_TAG}
docker run -d --name fhempy ghcr.io/fhem/fhempy-docker-<modulename>:{IMAGE_TAG}


# Supported Modules and their image

| Module | Image name |
{MODULES_IMAGE_LIST}

0 comments on commit f61cb2f

Please sign in to comment.