Skip to content

Auto Update OCI Image #2413

Auto Update OCI Image

Auto Update OCI Image #2413

Workflow file for this run

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-22.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@d1dafdb6e338bdab109e6afce581a01858680dfb # v0.7.0
with:
repository: zinclabs/zinc
excludes: prerelease, draft
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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-22.04
needs: check-upstream
if: ${{ needs.check-upstream.outputs.release != '' }}
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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
yq -i '.version = env(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@153407881ec5c347639a548ade7d8ad1d6740e38 # v5
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