diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index ebc625e3..c5d97d7d 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -17,10 +17,23 @@ jobs: with: github-token: "${{ secrets.GITHUB_TOKEN }}" + # Sample dependency updates need a human until changed samples can be + # tested without exposing deployment credentials to Dependabot PRs. + - name: Check whether sample files changed + id: scope + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + files=$(gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/files?per_page=100") + safe=$(jq '[.[][] | select(.filename | startswith("samples/"))] | length == 0' <<< "$files") + echo "safe=$safe" >> "$GITHUB_OUTPUT" + - name: Approve patch and minor updates if: | + steps.scope.outputs.safe == 'true' && ( steps.metadata.outputs.update-type == 'version-update:semver-patch' || - steps.metadata.outputs.update-type == 'version-update:semver-minor' + steps.metadata.outputs.update-type == 'version-update:semver-minor') run: gh pr review --approve "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }} @@ -28,8 +41,9 @@ jobs: - name: Enable auto-merge for patch and minor updates if: | + steps.scope.outputs.safe == 'true' && ( steps.metadata.outputs.update-type == 'version-update:semver-patch' || - steps.metadata.outputs.update-type == 'version-update:semver-minor' + steps.metadata.outputs.update-type == 'version-update:semver-minor') run: gh pr merge --auto --squash "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }} diff --git a/.github/workflows/test-scripts.yml b/.github/workflows/test-scripts.yml index 9a59a801..69526a23 100644 --- a/.github/workflows/test-scripts.yml +++ b/.github/workflows/test-scripts.yml @@ -5,11 +5,6 @@ permissions: on: pull_request: - paths: - - "scripts/**" - - "templates/**" - - "samples/**/compose.yaml" - - "samples/**/compose.yml" push: branches: - main @@ -66,3 +61,16 @@ jobs: script: | const script = require('./scripts/template-manager.js') await script({github, context, core}); + + ci: + name: ci + if: always() && github.event_name == 'pull_request' + needs: [test, preview-workflows] + runs-on: ubuntu-latest + permissions: {} + steps: + - name: Require script tests and workflow preview + env: + TEST: ${{ needs.test.result }} + PREVIEW: ${{ needs.preview-workflows.result }} + run: test "$TEST" = success && test "$PREVIEW" = success