Skip to content

Commit 122fe9c

Browse files
committed
Create wokflow to update ORAS_VERSION via auto-PR
1 parent c84703d commit 122fe9c

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/update-tools.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Update Tools in Scripts
2+
3+
permissions:
4+
contents: write
5+
pull-requests: write
6+
7+
on:
8+
workflow_dispatch:
9+
10+
push:
11+
branches:
12+
- 'test-workflow-update-oras'
13+
14+
schedule:
15+
- cron: '0 3 16 * *' # Run monthly at 03:00 AM, on the 16th day of the month
16+
17+
jobs:
18+
update-oras-version:
19+
name: Update ORAS version
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Get current ORAS version
27+
id: get-version-current
28+
run: |
29+
version_current=$(grep -Po '(?<=ORAS_VERSION=\${ORAS_VERSION:-)[0-9.]+(?=})' lib/functions/general/oci-oras.sh)
30+
echo "version_current=$version_current" >> $GITHUB_OUTPUT
31+
32+
- name: Get latest ORAS version
33+
id: get-version-latest
34+
# Multi-line string for changelog, see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
35+
run: |
36+
version_latest=$(curl --silent "https://api.github.com/repos/oras-project/oras/releases/latest" | jq -r .tag_name)
37+
version_latest=${version_latest#v} # Removing the 'v' prefix since the script uses only plain numbers
38+
changelog=$(curl --silent "https://api.github.com/repos/oras-project/oras/releases/latest" | jq -r .body)
39+
echo "version_latest=$version_latest" >> $GITHUB_OUTPUT
40+
{
41+
echo "changelog<<EOFF"
42+
$changelog
43+
echo EOFF
44+
} >> "$GITHUB_OUTPUT"
45+
46+
- name: Update ORAS_VERSION in script
47+
run: |
48+
version_latest=${{ steps.get-latest-oras.outputs.version_latest }}
49+
sed -i "s/ORAS_VERSION=\${ORAS_VERSION:-[0-9.]*}/ORAS_VERSION=\${ORAS_VERSION:-$version_latest}/g" lib/functions/general/oci-oras.sh
50+
51+
- name: Create Pull Request
52+
uses: peter-evans/create-pull-request@v6
53+
with:
54+
token: ${{ secrets.GITHUB_TOKEN }}
55+
commit-message: "Update `ORAS_VERSION` to ${{ steps.get-version-latest.outputs.version_latest }}"
56+
branch: update-oras-version-${{ steps.get-version-latest.outputs.version_latest }}
57+
title: "Bump `ORAS_VERSION` from ${{ steps.get-version-current.outputs.version_current }} to ${{ steps.get-version-latest.outputs.version_latest }}"
58+
body: |
59+
Bumps `ORAS_VERSION` from ${{ steps.get-current-version.outputs.old_version }} to ${{ steps.get-latest-version.outputs.latest_version }}.
60+
61+
**Release notes:**
62+
${{ steps.read-changelog.outputs.changelog }}
63+
64+
For more details, see the [release page](https://github.com/oras-project/oras/releases/tag/v${{ steps.get-latest-version.outputs.latest_version }}).
65+
labels: update, automated pr

0 commit comments

Comments
 (0)