-
Notifications
You must be signed in to change notification settings - Fork 40
fix: 🐛 dependabot-tidy workflow with stale cmd modules #789
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
Open
evaline-ju
wants to merge
1
commit into
rossoctl:main
Choose a base branch
from
evaline-ju:test-dependabot-tidy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| name: Dependabot go mod tidy | ||
|
|
||
| # When Dependabot bumps a dep in authbridge/authlib, the cmd/* modules' | ||
| # go.sum files go stale — they reference authlib's transitive deps via | ||
| # replace directives but Dependabot only tidies the directory it updated. | ||
| # CI's `go fmt`/`go vet` then fails with "updates to go.mod needed". | ||
| # | ||
| # Runs only on Dependabot PRs. Human PRs are untouched. | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - "authbridge/authlib/go.mod" | ||
| - "authbridge/authlib/go.sum" | ||
| - "authbridge/cmd/*/go.mod" | ||
| - "authbridge/cmd/*/go.sum" | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| tidy: | ||
| if: github.actor == 'dependabot[bot]' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| env: | ||
| GOWORK: "off" | ||
| GOTOOLCHAIN: local | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.head_ref }} | ||
|
|
||
| - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | ||
| with: | ||
| go-version-file: authbridge/authlib/go.mod | ||
|
|
||
| - name: Run go mod tidy in every module | ||
| run: | | ||
| set -euo pipefail | ||
| for mod in \ | ||
| authbridge/authlib \ | ||
| authbridge/cmd/authbridge-proxy \ | ||
| authbridge/cmd/authbridge-envoy \ | ||
| authbridge/cmd/abctl; do | ||
| if [ -f "$mod/go.mod" ]; then | ||
| echo "::group::go mod tidy in $mod" | ||
| (cd "$mod" && go mod tidy) | ||
| echo "::endgroup::" | ||
| fi | ||
| done | ||
|
|
||
| - name: Commit and push if changed | ||
| id: commit | ||
| run: | | ||
| set -euo pipefail | ||
| if [ -z "$(git status --porcelain)" ]; then | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| echo "No changes after tidy." | ||
| exit 0 | ||
| fi | ||
| git config user.name "dependabot[bot]" | ||
| git config user.email "49699333+dependabot[bot]@users.noreply.github.com" | ||
| git add -A | ||
| git commit -s -m "chore: go mod tidy across modules | ||
|
|
||
| Auto-tidied by dependabot-tidy workflow to keep cmd/* go.sum | ||
| files in sync with authlib after a Dependabot bump." | ||
| git push | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
|
|
||
| # Commits pushed with the default GITHUB_TOKEN do not re-trigger other | ||
| # workflows. Close + reopen forces CI to re-run on the new commit. | ||
| # (@dependabot rebase would discard our tidy commit, so it's not usable.) | ||
| - name: Re-trigger CI on the PR | ||
| if: steps.commit.outputs.changed == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh pr close "${{ github.event.pull_request.number }}" | ||
| gh pr reopen "${{ github.event.pull_request.number }}" | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: rossoctl/cortex
Length of output: 405
🏁 Script executed:
Repository: rossoctl/cortex
Length of output: 6836
🌐 Web query:
GitHub Actions GITHUB_TOKEN events do not trigger new workflow runs pull_request reopened approval required fork Dependabot documentation💡 Result:
By design, GitHub prevents recursive workflow execution by restricting the triggers of the default GITHUB_TOKEN [1][2]. When a workflow uses the GITHUB_TOKEN to perform actions such as creating or updating a pull request, subsequent pull_request events (specifically with the opened, synchronize, or reopened activity types) do not automatically trigger new workflow runs [1][3][2]. Instead, these events create workflow runs that are placed in an approval-required state [1][4]. A user with write access to the repository must manually approve these runs from the pull request interface before they will execute [1][2]. Other pull_request activity types, such as labeled or closed, do not trigger workflow runs at all when caused by the GITHUB_TOKEN [1][2]. Regarding Dependabot and automation requirements: 1. Recursive Prevention: This behavior is a security feature to prevent infinite loops (e.g., a workflow that triggers a push, which triggers the same workflow) [1][2]. 2. Overcoming Restrictions: To allow workflows to trigger automatically without manual approval, you must use a Personal Access Token (PAT) or a GitHub App installation access token instead of the GITHUB_TOKEN [1][2]. 3. Dependabot Specifics: Dependabot-initiated workflows have additional limitations, such as read-only GITHUB_TOKEN permissions by default and restricted access to repository secrets [5][6]. If you are using the pull_request event for Dependabot automation, your workflow may lack the necessary permissions or access to secrets [7][8]. Many developers use the pull_request_target event as an alternative when they need to perform actions (like auto-approving a PR) in the context of the base branch, which grants access to secrets and allows for more robust automation [8]. If you are encountering stuck workflows or require specific automations (like auto-merging or auto-approving), it is common practice to use a PAT with appropriate repository permissions [9][7][10]. Ensure that your workflow permissions (using the permissions key) are also explicitly set to provide the necessary scope (e.g., pull-requests: write) if you continue to use the GITHUB_TOKEN [7][6].
Citations:
GITHUB_TOKENgithub/docs#42693🏁 Script executed:
Repository: rossoctl/cortex
Length of output: 28223
🌐 Web query:
site:docs.github.com actions GITHUB_TOKEN events triggered by GITHUB_TOKEN workflow runs approval required pull_request reopened💡 Result:
In GitHub Actions, workflow runs triggered by the repository's GITHUB_TOKEN generally do not trigger further workflows to prevent infinite recursion [1][2][3]. However, there is a specific exception for the pull_request event. When a workflow uses the GITHUB_TOKEN to create or update a pull request with the opened, synchronize, or reopened activity types, the resulting pull_request event will trigger a workflow run, but it will be placed in an approval-required state [1][2][3]. When this happens, the pull request interface will display a banner in the merge box, and a user with write access to the repository must manually select Approve workflows to run to initiate the workflow [1][2][4]. Other pull_request activity types (such as labeled, edited, or closed) do not trigger new workflow runs even if they are performed via the GITHUB_TOKEN [1][3]. If you require workflow runs triggered by automation to execute automatically without manual approval, you must use a different authentication method, such as a GitHub App installation access token or a personal access token (PAT), instead of the GITHUB_TOKEN when performing the action that creates or updates the pull request [1][2][3]. The workflow_dispatch and repository_dispatch events are also exceptions and will always create workflow runs when triggered by the GITHUB_TOKEN [2][3][4].
Citations:
Use a non-
GITHUB_TOKENcredential for the CI retrigger.The
reopenedevent triggers CI in an approval-required state whenGITHUB_TOKENperforms the reopen. Use a GitHub App installation token or PAT with the minimum required pull-request permission.🤖 Prompt for AI Agents