-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a ci-update-workflow GitHub Actions to update the go-version matrix
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: ci-update-workflow | ||
|
||
on: | ||
schedule: | ||
# Run every hour. | ||
- cron: '0 * * * *' | ||
|
||
jobs: | ||
update-go-versions: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: 'auth' | ||
uses: 'google-github-actions/auth@v1' | ||
with: | ||
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | ||
|
||
- name: 'Set up Cloud SDK' | ||
uses: 'google-github-actions/setup-gcloud@v1' | ||
with: | ||
version: '423.0.0' | ||
|
||
- name: Get available Go versions | ||
run: | | ||
versions=$(gcloud functions runtimes list --format="value(NAME)" --project=test-asm-chizhg --region=us-west1 | grep ^go) | ||
echo "::set-output name=versions::$versions" | ||
id: get_versions | ||
|
||
- name: Checkout appengine repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Update Go versions | ||
run: | | ||
versions=($(echo "${{ steps.get_versions.outputs.versions }}" | tr ' ' '\n')) | ||
versions_str="" | ||
for version in "${versions[@]}"; do | ||
major=${version:2:1} | ||
minor=${version:3:2} | ||
versions_str+="'$major.$minor.x', " | ||
done | ||
# Remove the last comma and space | ||
versions_str=${versions_str%, *} | ||
# Only replace the first occurance | ||
sed -i "0,/^ go-version: \[.*/s// go-version: \[$versions_str\]/" .github/workflows/ci-v2.yaml | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
commit-message: Update go-version matrix | ||
title: Update go-version matrix | ||
body: | | ||
- go-version matrix updates | ||
Update the go-version matrix in the CI workflows to include the new supported runtimes. | ||
Auto-generated by [create-pull-request][1] | ||
|
||
[1]: https://github.com/peter-evans/create-pull-request | ||
branch: update-go-version-matrix |