generated from canonical/template-operator
-
Notifications
You must be signed in to change notification settings - Fork 11
76 lines (68 loc) · 2.93 KB
/
update-oci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Auto Update OCI Image
on:
# Manual trigger
workflow_dispatch:
# Check regularly the upstream every four hours
schedule:
- cron: "0 0 * * MON"
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@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # 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