From 196289adaee90dc3e7902784afd49831bb9d1238 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Fri, 3 Nov 2023 11:37:55 -0500 Subject: [PATCH 1/4] add update-openapi.yml --- .github/workflows/update-openapi.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/update-openapi.yml diff --git a/.github/workflows/update-openapi.yml b/.github/workflows/update-openapi.yml new file mode 100644 index 00000000000..829730d7800 --- /dev/null +++ b/.github/workflows/update-openapi.yml @@ -0,0 +1,19 @@ +on: + workflow_dispatch: { } + push: { } +jobs: + update-openapi: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version: 1.x + cache-dependency-path: "**/go.sum" + - name: update + env: + GITHUB_TOKEN: ${{ github.token }} + run: script/metadata.sh update-openapi From ae661f7eebfd056580e7633372ac1d775b766af9 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Fri, 3 Nov 2023 11:39:57 -0500 Subject: [PATCH 2/4] name it --- .github/workflows/update-openapi.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update-openapi.yml b/.github/workflows/update-openapi.yml index 829730d7800..14e892f3144 100644 --- a/.github/workflows/update-openapi.yml +++ b/.github/workflows/update-openapi.yml @@ -1,6 +1,7 @@ on: workflow_dispatch: { } push: { } +name: update-openapi jobs: update-openapi: runs-on: ubuntu-latest From 807cf997266c7aef7cf98b903b90ba7d713a06b5 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Fri, 3 Nov 2023 12:29:30 -0500 Subject: [PATCH 3/4] create PR --- .github/workflows/update-openapi.yml | 32 +++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-openapi.yml b/.github/workflows/update-openapi.yml index 14e892f3144..0aeedf28172 100644 --- a/.github/workflows/update-openapi.yml +++ b/.github/workflows/update-openapi.yml @@ -1,6 +1,7 @@ on: workflow_dispatch: { } - push: { } + schedule: + - cron: "23 15 * * *" name: update-openapi jobs: update-openapi: @@ -14,7 +15,32 @@ jobs: with: go-version: 1.x cache-dependency-path: "**/go.sum" - - name: update + - id: update + name: update env: GITHUB_TOKEN: ${{ github.token }} - run: script/metadata.sh update-openapi + run: | + script/metadata.sh update-openapi + if git diff --quiet openapi_operations.yaml; then + echo "No changes to openapi_operations.yaml" + exit 0 + fi + if script/generate.sh --check >/dev/null 2>&1; then + echo "No changes to generated code" + exit 0 + fi + script/generate.sh + # set NEEDS_PR output to 1 + echo "UPDATED=1" >> $GITHUB_OUTPUT + - name: create PR + uses: peter-evans/create-pull-request@v5.0.2 + if: steps.update.outputs.UPDATED == '1' + with: + token: ${{ github.token }} + commit-message: "Update openapi_operations.yaml" + title: "Update OpenAPI operations and generated code" + body: | + This PR was automatically generated by the update-openapi workflow. + Please review the changes and merge if they look good. + branch: "auto-update-openapi" + delete-branch: true From 7dec16d78e40ff6b9f04ef183b4831f2a352299a Mon Sep 17 00:00:00 2001 From: Will Roden Date: Fri, 3 Nov 2023 13:02:19 -0500 Subject: [PATCH 4/4] update action --- .github/workflows/update-openapi.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update-openapi.yml b/.github/workflows/update-openapi.yml index 0aeedf28172..191b49d736a 100644 --- a/.github/workflows/update-openapi.yml +++ b/.github/workflows/update-openapi.yml @@ -30,17 +30,16 @@ jobs: exit 0 fi script/generate.sh - # set NEEDS_PR output to 1 echo "UPDATED=1" >> $GITHUB_OUTPUT - name: create PR - uses: peter-evans/create-pull-request@v5.0.2 if: steps.update.outputs.UPDATED == '1' + uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 #v5.0.2 with: token: ${{ github.token }} - commit-message: "Update openapi_operations.yaml" + commit-message: "update openapi_operations.yaml and generated code" title: "Update OpenAPI operations and generated code" body: | - This PR was automatically generated by the update-openapi workflow. - Please review the changes and merge if they look good. - branch: "auto-update-openapi" + This PR was automatically generated by the update-openapi workflow in order to keep + the OpenAPI operations and generated code in sync with the latest changes to the + GitHub REST API. delete-branch: true