|
| 1 | +name: Generate SDK and Open PR |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: '0 12 * * 0' # Runs every Sunday at 12:00 UTC |
| 7 | + |
| 8 | + |
| 9 | +jobs: |
| 10 | + generate-sdk: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@v5 |
| 19 | + with: |
| 20 | + python-version: '3.11' |
| 21 | + |
| 22 | + - name: Run SDK generation script |
| 23 | + run: generate_openapi.sh |
| 24 | + |
| 25 | + - name: Check for changes |
| 26 | + id: check_changes |
| 27 | + run: | |
| 28 | + git diff --exit-code || echo "changes" |
| 29 | + |
| 30 | + - name: Commit changes |
| 31 | + if: steps.check_changes.outputs.changes == 'changes' |
| 32 | + run: | |
| 33 | + git config user.name "github-actions" |
| 34 | + git config user.email "[email protected]" |
| 35 | + git checkout -b feat/sdk-update-$(date +'%Y%m%d') |
| 36 | + git add . |
| 37 | + git commit -m "Update SDK from OpenAPI specs" |
| 38 | +
|
| 39 | + - name: Push changes to a new branch |
| 40 | + env: |
| 41 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + run: | |
| 43 | + git push origin feat/sdk-update-$(date +'%Y%m%d') |
| 44 | +
|
| 45 | + - name: Create a pull request |
| 46 | + id: create_pr |
| 47 | + uses: peter-evans/create-pull-request@v7 |
| 48 | + with: |
| 49 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + branch: sdk-update-$(date +'%Y%m%d') |
| 51 | + title: "OpenAPI SDK Update" |
| 52 | + body: "This PR updates the SDK based on the latest OpenAPI specifications." |
| 53 | + |
| 54 | + - name: Output PR URL |
| 55 | + if: steps.create_pr.outputs.pull-request-url != '' |
| 56 | + run: | |
| 57 | + echo "Pull Request URL: ${{ steps.create_pr.outputs.pull-request-url }}" |
| 58 | + |
0 commit comments