From 3bfc41b12aaf7fd5f96e6aece3878674cb56f607 Mon Sep 17 00:00:00 2001 From: Deepak Kumar Mishra Date: Thu, 9 Jul 2026 18:22:48 +0530 Subject: [PATCH] CLI-1827: Automate v3 API spec updates via daily cron PR Adds a composer script and GitHub Actions workflow that runs daily, downloads the latest v3 OpenAPI spec from the gateway URL, and automatically opens + auto-merges a PR when the spec changes. This means no manual release work is needed when the spec updates. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/update-v3-spec.yml | 54 ++++++++++++++++++++++++++++ composer.json | 3 ++ 2 files changed, 57 insertions(+) create mode 100644 .github/workflows/update-v3-spec.yml diff --git a/.github/workflows/update-v3-spec.yml b/.github/workflows/update-v3-spec.yml new file mode 100644 index 00000000..a44d3185 --- /dev/null +++ b/.github/workflows/update-v3-spec.yml @@ -0,0 +1,54 @@ +name: Update Acquia v3 API spec + +on: + schedule: + - cron: '0 3 * * *' + workflow_dispatch: + +jobs: + update-spec: + runs-on: ubuntu-24.04 + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v7 + + - uses: shivammathur/setup-php@v2 + with: + coverage: none + + - name: Install dependencies + run: composer install --no-interaction --prefer-dist --optimize-autoloader + + - name: Download latest v3 spec + run: composer update-acquia-v3-spec + + - name: Check for changes + id: diff + run: | + if git diff --quiet assets/acquia-v3-spec.yaml; then + echo "changed=false" >> $GITHUB_OUTPUT + else + echo "changed=true" >> $GITHUB_OUTPUT + fi + + - name: Create PR if spec changed + if: steps.diff.outputs.changed == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + BRANCH="automated/update-acquia-v3-spec-${{ github.run_id }}" + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git checkout -b "$BRANCH" + git add assets/acquia-v3-spec.yaml + git commit -m "chore: update Acquia v3 OpenAPI spec" + git push origin "$BRANCH" + gh pr create \ + --title "chore: update Acquia v3 OpenAPI spec" \ + --body "Automated spec update from https://api-specs-dev.dev.cicd.acquia.io/openapi.yaml" \ + --label "chore" \ + --base main \ + --head "$BRANCH" + gh pr merge "$BRANCH" --auto --squash diff --git a/composer.json b/composer.json index 9eb7b99b..3ac53033 100644 --- a/composer.json +++ b/composer.json @@ -119,6 +119,9 @@ "cp var/cx-api-spec/dist/spec/acquia-spec-prerelease.json assets/acquia-spec.json", "git -C var/cx-api-spec rev-parse HEAD > assets/acquia-spec.version" ], + "update-acquia-v3-spec": [ + "curl -sfL https://api-specs-dev.dev.cicd.acquia.io/openapi.yaml -o assets/acquia-v3-spec.yaml" + ], "update-acsf-api-spec": [ "rm -rf gardener", "git clone --single-branch -b master --depth 1 git@github.com:acquia/gardener.git",