Skip to content

Commit 5c90ded

Browse files
committed
Add a ci-update-workflow GitHub Actions to update the go-version matrix
Signed-off-by: Chi Zhang <[email protected]>
1 parent 917b599 commit 5c90ded

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: ci-update-workflow
2+
3+
on:
4+
schedule:
5+
# Run every day at 10AM.
6+
- cron: '0 10 * * *'
7+
8+
jobs:
9+
update-go-versions:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write # Enable OIDC
13+
steps:
14+
- id: 'auth'
15+
uses: 'google-github-actions/auth@v1'
16+
with:
17+
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
18+
19+
- name: 'Set up Cloud SDK'
20+
uses: 'google-github-actions/setup-gcloud@v1'
21+
with:
22+
version: '423.0.0'
23+
24+
- name: Get available Go versions
25+
run: |
26+
# Get all supported Go versions and pass the space-separated versions
27+
# string to the next step
28+
versions=$(gcloud functions runtimes list --format="value(NAME)" --project=gae-runtimes-private --region=us-west1 | grep ^go | tr '\n' ' ' | xargs)
29+
echo "::set-output name=versions::$versions"
30+
id: get_versions
31+
32+
- name: Checkout appengine repo
33+
uses: actions/checkout@v2
34+
35+
# Sign the commit.
36+
# https://www.chainguard.dev/unchained/keyless-git-commit-signing-with-gitsign-and-github-actions
37+
- uses: chainguard-dev/actions/setup-gitsign@main
38+
39+
- name: Update Go versions
40+
run: |
41+
readarray -d ' ' -t versions <<< "${{ steps.get_versions.outputs.versions }}"
42+
43+
versions_str=""
44+
for version in "${versions[@]}"; do
45+
major=${version:2:1}
46+
minor=${version:3:2}
47+
versions_str+="'$major.$minor.x', "
48+
done
49+
# Remove the last comma and space
50+
versions_str=${versions_str%, *}
51+
52+
# Only replace the first occurance
53+
sed -i "0,/^ go-version: \[.*/s// go-version: \[$versions_str\]/" .github/workflows/ci-v2.yaml
54+
55+
- name: Create Pull Request
56+
uses: peter-evans/create-pull-request@v4
57+
with:
58+
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
59+
commit-message: Update go-version matrix
60+
title: Update go-version matrix
61+
body: |
62+
- go-version matrix updates
63+
64+
Update the go-version matrix in the CI workflows to include the new supported runtimes.
65+
66+
Auto-generated by [create-pull-request][1]
67+
68+
[1]: https://github.com/peter-evans/create-pull-request
69+
branch: update-go-version-matrix
70+
reviewers: jinglundong

0 commit comments

Comments
 (0)