Skip to content

Auto Update OCI Image #4231

Auto Update OCI Image

Auto Update OCI Image #4231

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@v0.8.0
with:
repository: zinclabs/zinc
excludes: prerelease, draft
- name: Checkout repo
uses: actions/checkout@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@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@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@v6
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 <github-actions@github.com>"
author: "Github Actions <github-actions@github.com>"
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