Auto Update OCI Image #4570
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Update OCI Image | |
on: | |
# Manual trigger | |
workflow_dispatch: | |
# Check regularly the upstream every four hours | |
schedule: | |
- cron: "0 0,4,8,12,16,20 * * *" | |
jobs: | |
check-upstream: | |
runs-on: ubuntu-24.04 | |
outputs: | |
release: ${{steps.check.outputs.release}} | |
steps: | |
# Get the latest release of zinclabs/zinc in format 'vX.X.X' | |
- id: latest-upstream | |
uses: pozetroninc/github-action-get-latest-release@2a61c339ea7ef0a336d1daa35ef0cb1418e7676c # v0.8.0 | |
with: | |
repository: zinclabs/zinc | |
excludes: prerelease, draft | |
- name: Checkout repo | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- id: check | |
name: Check for new releases | |
run: | | |
LATEST="${{ steps.latest-upstream.outputs.release }}" | |
# Get the current version from the repo | |
CURRENT="$(yq '.version' rockcraft.yaml)" | |
if [[ "$CURRENT" < "$LATEST" ]]; then | |
echo "release=$LATEST" >> $GITHUB_OUTPUT | |
echo "New upstream release '$LATEST' found" | |
else | |
echo "No new upstream release found" | |
fi | |
create-pr: | |
runs-on: ubuntu-24.04 | |
needs: check-upstream | |
if: ${{ needs.check-upstream.outputs.release != '' }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Update version | |
run: | | |
# Grab the output from the last job | |
upstream="${{ needs.check-upstream.outputs.release }}" | |
# Strip the leading 'v' from the upstream release version | |
export latest="${upstream/v/}" | |
# Update the version in the rockcraft.yaml | |
sed -i 's/^\(version: \).*$/\1'"$latest"'/' rockcraft.yaml | |
# We use a Github App and token to allow Github Actions to run properly on the created PR. | |
- uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2 | |
id: generate-token | |
with: | |
app_id: ${{ secrets.APP_ID }} | |
private_key: ${{ secrets.APP_KEY }} | |
- name: Create a PR for local changes | |
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7 | |
id: cpr | |
with: | |
token: ${{ steps.generate-token.outputs.token }} | |
commit-message: "chore(deps): bump zinc version to ${{ needs.check-upstream.outputs.release }}" | |
committer: "Github Actions <[email protected]>" | |
author: "Github Actions <[email protected]>" | |
title: "chore(deps): bump to Zinc ${{ needs.check-upstream.outputs.release }}" | |
body: Automated update to follow upstream [release](https://github.com/zinclabs/zinc/releases/tag/${{ needs.check-upstream.outputs.release }}) of Zinc ${{ needs.check-upstream.outputs.release }}. | |
branch: "auto-${{ needs.check-upstream.outputs.release }}" | |
delete-branch: true | |
reviewers: jnsgruk | |
assignees: jnsgruk |