Skip to content

Commit a858869

Browse files
authored
Add a ci-update-workflow GitHub Actions to update the go-version matrix (#307)
Signed-off-by: Chi Zhang <[email protected]>
1 parent 917b599 commit a858869

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
22+
- name: Get available Go versions
23+
run: |
24+
# Get all supported Go versions and pass the space-separated versions
25+
# string to the next step
26+
versions=$(gcloud functions runtimes list --format="value(NAME)" --project=gae-runtimes-private --region=us-west1 | grep ^go | tr '\n' ' ' | xargs)
27+
echo "::set-output name=versions::$versions"
28+
id: get_versions
29+
30+
- name: Checkout appengine repo
31+
uses: actions/checkout@v2
32+
33+
# Sign the commit.
34+
# https://www.chainguard.dev/unchained/keyless-git-commit-signing-with-gitsign-and-github-actions
35+
- uses: chainguard-dev/actions/setup-gitsign@main
36+
37+
- name: Update Go versions
38+
run: |
39+
readarray -d ' ' -t versions <<< "${{ steps.get_versions.outputs.versions }}"
40+
41+
versions_str=""
42+
for version in "${versions[@]}"; do
43+
major=${version:2:1}
44+
minor=${version:3:2}
45+
versions_str+="'$major.$minor.x', "
46+
done
47+
# Remove the last comma and space
48+
versions_str=${versions_str%, *}
49+
50+
# Only replace the first occurance
51+
sed -i "0,/^ go-version: \[.*/s// go-version: \[$versions_str\]/" .github/workflows/ci-v2.yaml
52+
53+
- name: Create Pull Request
54+
uses: peter-evans/create-pull-request@v4
55+
with:
56+
token: ${{ secrets.GITHUB_TOKEN }}
57+
commit-message: Update go-version matrix
58+
title: Update go-version matrix
59+
body: |
60+
- go-version matrix updates
61+
62+
Update the go-version matrix in the CI workflows to include the new supported runtimes.
63+
64+
Auto-generated by [create-pull-request][1]
65+
66+
[1]: https://github.com/peter-evans/create-pull-request
67+
branch: update-go-version-matrix
68+
reviewers: jinglundong

0 commit comments

Comments
 (0)