Repository navigation
ci: prepare for merge queue and approve Dependabot PRs as a code owner #463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,13 @@ | ||
| # Default all repository changes to the CLI team. | ||
| * @supabase/cli | ||
|
|
||
| # Files that Dependabot updates. Either owner satisfies code-owner review; `supabase-oss` | ||
| # approves only Dependabot PRs, through dependabot.yml. | ||
| /.github/workflows/*.yml @supabase/cli @supabase-oss | ||
| /action.yml @supabase/cli @supabase-oss | ||
| /package.json @supabase/cli @supabase-oss | ||
| /bun.lock @supabase/cli @supabase-oss | ||
|
|
||
| # Dependabot PRs touching this workflow still need a maintainer: it runs with secrets. | ||
| # Last matching pattern wins. | ||
| /.github/workflows/dependabot.yml @supabase/cli | ||
|
jgoux marked this conversation as resolved.
Resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,80 @@ | ||
| # Adapted from https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request | ||
| name: Dependabot auto-merge | ||
|
|
||
| on: pull_request | ||
| on: | ||
| # Dependabot-triggered pull_request runs get no Actions or environment secrets. Only this | ||
| # event lets the job use the auto-approve environment's secret. The job never checks out or | ||
| # runs code from the pull request. | ||
| # jactionlint ignore=dangerous-triggers | ||
| pull_request_target: | ||
| types: [opened, reopened, synchronize, ready_for_review] | ||
| branches: [main] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| pull-requests: write | ||
| contents: write | ||
| permissions: {} | ||
|
|
||
| jobs: | ||
| dependabot: | ||
| name: Approve and enable auto-merge | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| # Only act on PRs opened by Dependabot from branches in this repository. | ||
| if: github.actor == 'dependabot[bot]' && github.repository == github.event.pull_request.head.repo.full_name | ||
| # The first condition checks who opened the pull request. The second checks who caused this | ||
| # event, so a person pushing to a Dependabot pull request does not get it approved. Only | ||
| # branches in this repository qualify. | ||
| # jactionlint ignore=bot-conditions | ||
| if: >- | ||
| github.event.pull_request.user.login == 'dependabot[bot]' && | ||
| github.event.sender.login == 'dependabot[bot]' && | ||
| github.event.pull_request.head.repo.full_name == github.repository && | ||
| !github.event.pull_request.draft | ||
| # Holds `AUTO_APPROVE_PR_PAT`; the environment only deploys from the default branch. | ||
| environment: auto-approve | ||
| # The built-in token only reads; the PAT approves and the app token enables auto-merge. | ||
| permissions: | ||
| pull-requests: read | ||
| contents: read | ||
| steps: | ||
| # pull_request_target is safe here because this job never checks out PR code. | ||
| # Metadata drives the non-major gating used for approval and auto-merge. | ||
| - id: meta | ||
| uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0 | ||
| with: | ||
| github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
|
|
||
| # The org ruleset requires a code-owner review, which an app approval cannot satisfy. | ||
| # `supabase-oss` is a co-owner of the files Dependabot updates (see CODEOWNERS). A rewritten | ||
| # PR keeps its approval; skipping it avoids stacking a review per push. | ||
| - name: Approve a PR | ||
| if: ${{ steps.meta.outputs.update-type == null || steps.meta.outputs.update-type == 'version-update:semver-patch' || steps.meta.outputs.update-type == 'version-update:semver-minor' }} | ||
| run: | | ||
| set -euo pipefail | ||
| decision="$(GH_TOKEN="$READ_TOKEN" gh pr view --repo "$GITHUB_REPOSITORY" "$PR_NUMBER" --json reviewDecision --jq .reviewDecision)" | ||
| if [ "$decision" != "APPROVED" ]; then | ||
| gh pr review --approve --repo "$GITHUB_REPOSITORY" "$PR_NUMBER" | ||
| fi | ||
| env: | ||
| GH_TOKEN: ${{ secrets.AUTO_APPROVE_PR_PAT }} | ||
|
jgoux marked this conversation as resolved.
Resolved
|
||
| READ_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
|
|
||
| # The built-in GITHUB_TOKEN cannot add pull requests to a merge queue, and the merge group | ||
| # it would create would not trigger the required checks. | ||
| - name: Generate token | ||
| id: app-token | ||
| if: ${{ steps.meta.outputs.update-type == null || steps.meta.outputs.update-type == 'version-update:semver-patch' || steps.meta.outputs.update-type == 'version-update:semver-minor' }} | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | ||
| with: | ||
| app-id: ${{ secrets.APP_ID }} | ||
| private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | ||
|
|
||
| - name: Approve a PR | ||
| if: ${{ steps.meta.outputs.update-type == null || steps.meta.outputs.update-type == 'version-update:semver-patch' || steps.meta.outputs.update-type == 'version-update:semver-minor' }} | ||
| run: gh pr review --approve "$PR_URL" | ||
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| permission-contents: write | ||
| permission-pull-requests: write | ||
|
|
||
| - name: Enable auto-merge for Dependabot PRs | ||
| if: ${{ steps.meta.outputs.update-type == null || steps.meta.outputs.update-type == 'version-update:semver-patch' || steps.meta.outputs.update-type == 'version-update:semver-minor' }} | ||
| run: gh pr merge --auto --squash "$PR_URL" | ||
| run: gh pr merge --auto --squash --repo "$GITHUB_REPOSITORY" "$PR_NUMBER" | ||
| env: | ||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.