-
-
Notifications
You must be signed in to change notification settings - Fork 274
feat: add Update Changelogs workflow with auto-changelog v6 --checkDeps #8443
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
cryptodev-2s
wants to merge
15
commits into
main
Choose a base branch
from
feat/auto-changelog-check-deps
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.
+122
−0
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
61175c2
feat: adopt auto-changelog v6 --checkDeps for dependency bump validation
cryptodev-2s a83983a
fix: correct --checkDeps usage and handle main branch
cryptodev-2s 02fd302
fix: trigger fix-changelogs via @metamaskbot check-deps PR comment
cryptodev-2s 14d0298
revert: remove --checkDeps from validate-changelog.sh
cryptodev-2s 9c0924f
fix: use env vars to prevent code injection in fix-changelogs workflow
cryptodev-2s f3192c6
fix: skip fix-changelogs workflow on fork PRs
cryptodev-2s 925ca11
fix: address code review findings in fix-changelogs workflow
cryptodev-2s a62d2ee
fix: address review feedback for fix-changelogs workflow
cryptodev-2s b6cf542
fix: remove unnecessary yarn changelog:update step
cryptodev-2s b516c86
fix: move reaction step first and report push failures in comment
cryptodev-2s 455620a
fix: remove unnecessary checkout from fork detection job
cryptodev-2s 9069a65
feat: auto-trigger fix-changelogs on release PR open
cryptodev-2s 5a137b1
fix: rename workflow to update-changelogs
cryptodev-2s 61a4b9e
fix: add job timeout and defensive git add separator
cryptodev-2s f4aabbb
fix: address remaining review findings
cryptodev-2s 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,122 @@ | ||
| name: Update Changelogs | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
| pull_request: | ||
| branches: [main] | ||
| types: [opened] | ||
|
|
||
| concurrency: | ||
| group: update-changelogs-${{ github.event.issue.number || github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| is-fork-pull-request: | ||
| name: Determine whether this PR is from a fork | ||
| if: > | ||
| (github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/')) || | ||
| (github.event.issue.pull_request && contains(github.event.comment.body, '@metamaskbot update-changelogs')) | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| IS_FORK: ${{ steps.is-fork.outputs.IS_FORK }} | ||
| steps: | ||
| - name: Determine whether this PR is from a fork | ||
| id: is-fork | ||
| run: | | ||
| IS_FORK=$(gh pr view --json isCrossRepository --jq '.isCrossRepository' "$PR_NUMBER" --repo "$GITHUB_REPOSITORY") | ||
| echo "IS_FORK=$IS_FORK" >> "$GITHUB_OUTPUT" | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }} | ||
|
|
||
| update-changelogs: | ||
| name: Update changelogs | ||
| needs: is-fork-pull-request | ||
| if: ${{ needs.is-fork-pull-request.outputs.IS_FORK == 'false' }} | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - name: React to comment | ||
| if: github.event_name == 'issue_comment' | ||
| run: gh api "repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}/reactions" -f content='+1' | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| COMMENT_ID: ${{ github.event.comment.id }} | ||
|
|
||
| - name: Get PR head ref | ||
| id: pr | ||
| run: | | ||
| PR_DATA=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq '{ref: .head.ref, sha: .head.sha}') | ||
| echo "ref=$(echo "$PR_DATA" | jq -r .ref)" >> "$GITHUB_OUTPUT" | ||
| echo "sha=$(echo "$PR_DATA" | jq -r .sha)" >> "$GITHUB_OUTPUT" | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| PR_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }} | ||
|
|
||
| - name: Checkout and setup environment | ||
| uses: MetaMask/action-checkout-and-setup@v2 | ||
| with: | ||
| is-high-risk-environment: false | ||
| cache-node-modules: true | ||
| node-version: 22.x | ||
| ref: ${{ steps.pr.outputs.sha }} | ||
|
|
||
| # Fetch and checkout by branch name so git push targets the correct branch | ||
| - name: Checkout PR branch | ||
| run: | | ||
| git fetch origin "$PR_REF" | ||
| git checkout "$PR_REF" | ||
| env: | ||
| PR_REF: ${{ steps.pr.outputs.ref }} | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Validate and fix dependency bump entries | ||
| id: validate | ||
| run: > | ||
| yarn workspaces foreach --all --no-private --parallel --interlaced --verbose | ||
| run changelog:validate --checkDeps --fix --currentPr "$PR_NUMBER" | ||
| continue-on-error: true | ||
| env: | ||
| PR_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }} | ||
cryptodev-2s marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Commit and push if changed | ||
| id: commit | ||
| run: | | ||
| if git diff --quiet; then | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| git diff --stat | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| git add -- '**/CHANGELOG.md' | ||
| git commit -m "chore: auto-fix dependency bump changelog entries" | ||
| git push | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Comment result | ||
| if: always() | ||
| run: | | ||
| if [ "$CHANGED" = "true" ] && [ "$VALIDATE_OUTCOME" = "failure" ]; then | ||
| gh pr comment "$PR_NUMBER" --body "Changelogs updated and pushed, but some validation errors remain. Check the [workflow run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) for details." | ||
| elif [ "$CHANGED" = "true" ]; then | ||
| gh pr comment "$PR_NUMBER" --body "Changelogs updated and pushed." | ||
| elif [ "$COMMIT_OUTCOME" = "failure" ]; then | ||
| gh pr comment "$PR_NUMBER" --body "Failed to push changelog fixes. Check the [workflow run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) for details." | ||
| elif [ "$VALIDATE_OUTCOME" = "failure" ]; then | ||
| gh pr comment "$PR_NUMBER" --body "Changelog validation failed. Check the [workflow run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) for details." | ||
| elif [ "$VALIDATE_OUTCOME" = "skipped" ] || [ "$COMMIT_OUTCOME" = "skipped" ]; then | ||
| gh pr comment "$PR_NUMBER" --body "Workflow failed before changelog validation. Check the [workflow run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) for details." | ||
| else | ||
| gh pr comment "$PR_NUMBER" --body "No changelog changes needed." | ||
| fi | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| PR_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }} | ||
| CHANGED: ${{ steps.commit.outputs.changed }} | ||
| COMMIT_OUTCOME: ${{ steps.commit.outcome }} | ||
| VALIDATE_OUTCOME: ${{ steps.validate.outcome }} | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.