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 3f651125..3ac53033 100644 --- a/composer.json +++ b/composer.json @@ -120,13 +120,7 @@ "git -C var/cx-api-spec rev-parse HEAD > assets/acquia-spec.version" ], "update-acquia-v3-spec": [ - "rm -rf var/api-specs", - "git clone --depth 1 git@github.com:acquia/api-specs.git var/api-specs", - "npm install --prefix var/api-specs @redocly/cli@latest --no-save --ignore-scripts", - "cd var/api-specs && PATH=$(pwd)/node_modules/.bin:$PATH make bundle", - "cd var/api-specs && npx --yes @redocly/cli@latest bundle --config redocly.bundle.yaml dist/openapi.yaml --dereferenced --ext json -o ../../assets/acquia-v3-spec.json", - "git -C var/api-specs rev-parse HEAD > assets/acquia-v3-spec.version", - "rm -rf var/api-specs" + "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",