chore(ci): add api-sync codegen automation workflow #2
Workflow file for this run
This file contains hidden or 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
| name: API Sync | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" # Run at midnight every day | |
| workflow_dispatch: # Allow manual triggering | |
| pull_request: # Allow running on PRs | |
| jobs: | |
| sync: | |
| name: Sync API | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Run codegen | |
| run: go generate | |
| - name: Check for changes | |
| id: check | |
| run: | | |
| if git diff --ignore-space-at-eol --exit-code --quiet pkg; then | |
| echo "No changes detected" | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Changes detected" | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Pull Request | |
| if: steps.check.outputs.has_changes == 'true' | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "chore: sync API changes" | |
| title: "chore: sync API changes" | |
| body: | | |
| This PR was automatically created to sync API changes. | |
| Changes were detected in the generated API code. Please review the changes before merging. | |
| branch: sync/api-changes | |
| base: develop | |
| labels: | | |
| automated pr | |
| api-sync |