chore(deps): bump the web-minor-and-patch group across 1 directory with 13 updates #722
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
| name: PR Branch Status Check | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| check-branch-status: | |
| runs-on: ubuntu-latest | |
| env: | |
| BASE_REF: ${{ github.event.pull_request.base.ref }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Fetch base branch | |
| run: | | |
| git fetch origin "$BASE_REF" | |
| - name: Check if PR is behind base | |
| id: check | |
| run: | | |
| # Get base and head refs | |
| BASE="$BASE_REF" | |
| HEAD="${{ github.event.pull_request.head.sha }}" | |
| # Count commits behind and ahead | |
| COUNTS=$(git rev-list --left-right --count "origin/$BASE...$HEAD") | |
| BEHIND=$(echo "$COUNTS" | cut -d' ' -f1) | |
| AHEAD=$(echo "$COUNTS" | cut -d' ' -f2) | |
| echo "behind=$BEHIND" >> "$GITHUB_OUTPUT" | |
| echo "ahead=$AHEAD" >> "$GITHUB_OUTPUT" | |
| # Log the status | |
| echo "Branch Status:" | |
| echo " - $BEHIND commits behind $BASE" | |
| echo " - $AHEAD commits ahead of $BASE" | |
| # Fail if behind | |
| if [ "$BEHIND" -gt 0 ]; then | |
| echo "::error::This PR is $BEHIND commits behind $BASE. Please rebase or merge $BASE into your branch." | |
| exit 1 | |
| else | |
| echo "::notice::Branch is up to date with $BASE ($AHEAD commits ahead)" | |
| fi | |
| - name: Add PR comment | |
| if: ${{ failure() }} | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| env: | |
| BRANCH_STATUS_BEHIND: ${{ steps.check.outputs.behind }} | |
| BRANCH_STATUS_AHEAD: ${{ steps.check.outputs.ahead }} | |
| BRANCH_STATUS_BASE: ${{ github.event.pull_request.base.ref }} | |
| BRANCH_STATUS_HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
| with: | |
| script: | | |
| const behind = process.env.BRANCH_STATUS_BEHIND; | |
| const ahead = process.env.BRANCH_STATUS_AHEAD; | |
| const base = process.env.BRANCH_STATUS_BASE; | |
| const headRef = process.env.BRANCH_STATUS_HEAD_REF; | |
| const body = [ | |
| '## Branch Out of Date', | |
| '', | |
| 'This PR is **' + behind + ' commits behind** `' + base + '`.', | |
| '', | |
| '**Status:**', | |
| '- ' + behind + ' commits behind `' + base + '`', | |
| '- ' + ahead + ' commits ahead of `' + base + '`', | |
| '', | |
| '**Action Required:**', | |
| 'Please update your branch to include the latest changes from `' + base + '`:', | |
| '', | |
| '```bash', | |
| 'git checkout ' + headRef, | |
| 'git merge origin/' + base, | |
| '# Or for a cleaner history:', | |
| 'git rebase origin/' + base, | |
| '```', | |
| '', | |
| 'Once updated, this check will pass automatically.' | |
| ].join('\n'); | |
| await github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: body | |
| }); |