Skip to content

Commit

Permalink
Auto Alpine release checker (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
zinen authored Mar 15, 2023
1 parent d6e27ab commit 5f22b88
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 51 deletions.
48 changes: 24 additions & 24 deletions .github/workflows/docker-publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
# Run when file is edited
- Dockerfile
- start.sh
- release-versions/pigpio-latest.log
- release-versions/*
- .github/workflows/docker-publish-image.yml

# Run tests for any PRs.
Expand All @@ -21,7 +21,7 @@ on:
version:
description: 'Version of pigpio to get'
required: true
default: 'v78'
default: 'v79'

env:
# Image name at Docker Hub
Expand All @@ -41,13 +41,13 @@ jobs:
if: github.event_name == 'workflow_dispatch'
run: |
# Write content of input form workflow_dispatch to file
echo ${{ github.event.inputs.version }} > release-versions/pigpio-latest.log
echo ${{ github.event.inputs.version }} > release-versions/pigpio-latest.txt
- name: Modify Dockerfile pigpio version
run: |
# Change download link inside Dockerfile to match pigpio version stated here
# this is only relevant if two releases are made in a short time
PIGPIO_VERSION=$(cat release-versions/pigpio-latest.log)
PIGPIO_VERSION=$(cat release-versions/pigpio-latest.txt)
sed -i "s/master/$PIGPIO_VERSION/" Dockerfile
# Show new Dockerfile content
cat Dockerfile
Expand Down Expand Up @@ -88,12 +88,12 @@ jobs:
if: github.event_name == 'workflow_dispatch'
run: |
# Write content of input form workflow_dispatch to file
echo ${{ github.event.inputs.version }} > release-versions/pigpio-latest.log
echo ${{ github.event.inputs.version }} > release-versions/pigpio-latest.txt
- name: Modify Dockerfile pigpio version
run: |
# Add label of pigpio version to Dockerfile eg. 'v78'
PIGPIO_VERSION=$(cat release-versions/pigpio-latest.log)
PIGPIO_VERSION=$(cat release-versions/pigpio-latest.txt)
echo "LABEL pigpio_version=$PIGPIO_VERSION" >> Dockerfile
# Add variable as a global environment variable
echo "PIGPIO_VERSION=$PIGPIO_VERSION" >> $GITHUB_ENV
Expand Down Expand Up @@ -131,25 +131,25 @@ jobs:
${{ env.IMAGE_NAME }}:arm32v6-pigpio-${{ env.PIGPIO_VERSION }}
${{ env.IMAGE_NAME }}:arm32v6
- name: Build and push arm32v7
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/arm/v7
push: true
tags: |
${{ env.IMAGE_NAME }}:arm32v7
# - name: Build and push arm32v7
# uses: docker/build-push-action@v3
# with:
# context: .
# file: ./Dockerfile
# platforms: linux/arm/v7
# push: true
# tags: |
# ${{ env.IMAGE_NAME }}:arm32v7

- name: Build and push arm64v8
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/arm64
push: true
tags: |
${{ env.IMAGE_NAME }}:arm64v8
# - name: Build and push arm64v8
# uses: docker/build-push-action@v3
# with:
# context: .
# file: ./Dockerfile
# platforms: linux/arm64
# push: true
# tags: |
# ${{ env.IMAGE_NAME }}:arm64v8

- name: Build and push latest
uses: docker/build-push-action@v3
Expand Down
27 changes: 4 additions & 23 deletions .github/workflows/get-last-release-pigpio.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Get latest release tag
name: Get latest pigpio release tag
on:
push:
branches:
Expand All @@ -18,7 +18,7 @@ env:
REPO_TITLE: pigpio

jobs:
get-version:
get-pigpio-version:
runs-on: ubuntu-latest
steps:
- name: Check out
Expand All @@ -36,26 +36,7 @@ jobs:
# Print the found release
echo Release tag $RELEASE_TAG
# Save the found release to a file in folder(folder must be there before)
echo $RELEASE_TAG > release-versions/$REPO_TITLE-latest.log
# - name: Create Pull Request # Does so only if any files in repo have changed
# uses: peter-evans/create-pull-request@v3
# with:
# token: ${{ secrets.PAT }}
# commit-message: Update ${{ env.REPO_TITLE }} to ${{ env.RELEASE_TAG }}
# committer: bot_${{ github.event_name }} <bot_${{ github.event_name }}@users.noreply.github.com>
# # author cant be changed from owner when using PAT issue#48
# branch: auto-new-${{ env.REPO_TITLE }}-release
# delete-branch: true
# title: Update ${{ env.REPO_TITLE }} to ${{ env.RELEASE_TAG }}
# body: |
# Update ${{ env.REPO_TITLE }} to release ${{ env.RELEASE_TAG }}
#
# - Auto-generated by [create-pull-request][1]
#
# [1]: https://github.com/peter-evans/create-pull-request
# labels: auto-pr
# assignees: zinen
echo $RELEASE_TAG > release-versions/$REPO_TITLE-latest.txt
- name: Push changes
# This needs actions/checkout to be able push to repo
Expand All @@ -65,5 +46,5 @@ jobs:
# Add all files to commit in current and sub folders
git add .
# Check if something changed and then commit
git diff --quiet HEAD || git commit -m "A ${{ github.event_name }} added this"
git diff --quiet HEAD || git commit -m "Auto. A ${{ github.event_name }} added this"
git push
67 changes: 67 additions & 0 deletions .github/workflows/get-latest-alpine-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Get latest alpine release
on:
push:
#branches:
# - main
paths:
# Run when file is edited
- .github/workflows/get-latest-alpine-release.yml

schedule:
- cron: '0 9 * * *'

workflow_dispatch:

jobs:
get-alpine-release-date:
runs-on: ubuntu-latest
steps:
# Login to docker is not nessasary for lucacome/[email protected]
# - name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Docker Image Update Checker
id: check
uses: lucacome/[email protected]
with:
base-image: alpine:latest
image: zinen2/alpine-pigpiod:latest
# Platforms with variants removed due to issue https://github.com/lucacome/docker-image-update-checker/issues/27
# platforms: linux/arm/v6,linux/arm/v7,linux/arm64
platforms: linux/arm64
# env:
# DEBUG: true

push-alpine-release-date:
needs: get-alpine-release-date
if: needs.check.outputs.needs-updating == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
# Use PAT so allow this action to trigger a new action
token: ${{ secrets.PAT }}

- name: Check result
run: |
echo "Needs updating: ${{ steps.check.outputs.needs-updating }}"
CURRENT_TIME=$( date )
echo Checked time $CURRENT_TIME
# Save the current checked time to a file in folder(folder must be there before)
echo Checked time $CURRENT_TIME > release-versions/alpine-new-release.txt
cat release-versions/alpine-new-release.txt
- name: Push changes
# This needs actions/checkout to be able push to repo
run: |
git config user.name "bot_${{ github.event_name }}"
git config user.email "bot_${{ github.event_name }}@users.noreply.github.com"
# Add all files to commit in current and sub folders
git add .
# Check if something changed and then commit
git diff --quiet HEAD || git commit -m "Auto. A ${{ github.event_name }} added this"
git push
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ E.g. for running on Raspberry Pi 1 this worked for me: `docker run -it -p 8888:8
| Device Name | Docker image tag | Tested?* ✔/❌| [pigpio version tested][pigpio-release] |
| --- | --- | --- | --- |
| Raspberry Pi (1, Zero, Zero W) | zinen2/alpine-pigpiod:arm32v6 | ✔ yes, works on rpi1 | 76 |
| Raspberry Pi 2 | zinen2/alpine-pigpiod:arm32v7 | ✔ yes, works #19 | 79 |
| Raspberry Pi 3 (32bit) | zinen2/alpine-pigpiod:arm32v7 | ✔ yes, works | 76, 78 |
| Raspberry Pi 3 (64bit) | zinen2/alpine-pigpiod:arm64v8 | ✔ yes, works | 78 |
| Raspberry Pi 4 | zinen2/alpine-pigpiod:arm64v8 | ✔ yes, works | 78 |
| Raspberry Pi 2 | zinen2/alpine-pigpiod:latest | ✔ yes, works #19 | 79 |
| Raspberry Pi 3 (32bit) | zinen2/alpine-pigpiod:latest | ✔ yes, works | 76, 78 |
| Raspberry Pi 3 (64bit) | zinen2/alpine-pigpiod:latest | ✔ yes, works | 78 |
| Raspberry Pi 4 | zinen2/alpine-pigpiod:latest | ✔ yes, works | 78 |

Some problems can also be fixed by running the container privileged. In that case you can try this `docker run -it -p 8888:8888 --privileged zinen2/alpine-pigpiod`

Expand Down
1 change: 1 addition & 0 deletions release-versions/alpine-new-release.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Checked time Wed Mar 15 10:07:04 UTC 2023

0 comments on commit 5f22b88

Please sign in to comment.