Skip to content

Commit d5de030

Browse files
committed
Add a ci-update-workflow GitHub Actions to update the go-version matrix
1 parent 917b599 commit d5de030

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: ci-update-workflow
2+
3+
on:
4+
schedule:
5+
# Run every hour.
6+
- cron: '0 * * * *'
7+
8+
jobs:
9+
update-go-versions:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- id: 'auth'
13+
uses: 'google-github-actions/auth@v1'
14+
with:
15+
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
16+
17+
- name: 'Set up Cloud SDK'
18+
uses: 'google-github-actions/setup-gcloud@v1'
19+
with:
20+
version: '423.0.0'
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+
- name: Update Go versions
34+
run: |
35+
readarray -d ' ' -t versions <<< "${{ steps.get_versions.outputs.versions }}"
36+
37+
versions_str=""
38+
for version in "${versions[@]}"; do
39+
major=${version:2:1}
40+
minor=${version:3:2}
41+
versions_str+="'$major.$minor.x', "
42+
done
43+
# Remove the last comma and space
44+
versions_str=${versions_str%, *}
45+
46+
# Only replace the first occurance
47+
sed -i "0,/^ go-version: \[.*/s// go-version: \[$versions_str\]/" .github/workflows/ci-v2.yaml
48+
49+
- name: Create Pull Request
50+
uses: peter-evans/create-pull-request@v4
51+
with:
52+
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
53+
commit-message: Update go-version matrix
54+
title: Update go-version matrix
55+
body: |
56+
- go-version matrix updates
57+
58+
Update the go-version matrix in the CI workflows to include the new supported runtimes.
59+
60+
Auto-generated by [create-pull-request][1]
61+
62+
[1]: https://github.com/peter-evans/create-pull-request
63+
branch: update-go-version-matrix

0 commit comments

Comments
 (0)