-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add update schemas workflow (#1895)
- Loading branch information
Showing
9 changed files
with
169 additions
and
42 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
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,51 @@ | ||
name: Update Schemas | ||
|
||
on: | ||
schedule: | ||
- cron: 0 5 * * 1-5 | ||
workflow_dispatch: {} | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
updater: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
- run: go install golang.org/x/tools/cmd/goimports@latest | ||
- uses: arduino/setup-task@v2 | ||
- id: update | ||
run: make schemas-update | ||
- id: date | ||
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
- id: changes | ||
run: echo "changes=$(git diff CHANGELOG.md | awk '/^\+[ -]/ {print substr($0, 2)}')" >> $GITHUB_OUTPUT | ||
- id: create_pr | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
author: GitHub <[email protected]> | ||
body: ${{ steps.changes.outputs.changes }} | ||
branch: update/${{ steps.date.outputs.date }}-${{ github.run_id }} | ||
commit-message: "chore(update): update schemas (${{ steps.date.outputs.date }})" | ||
labels: | | ||
dependencies | ||
- name: Close previous update PRs | ||
if: steps.create_pr.outputs.pull-request-operation == 'created' | ||
run: | | ||
new_pr_number=${{ steps.create_pr.outputs.pull-request-number }} | ||
prs=$(gh pr list --state open --json number,headRefName --jq '.[] | select(.headRefName | startswith("update/")) | .number') | ||
for pr in $prs; do | ||
if [ "$pr" != "$new_pr_number" ]; then | ||
gh pr close $pr --comment "Auto-closing pull request in favor of #$new_pr_number" --delete-branch | ||
fi | ||
done | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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