Skip to content

Commit

Permalink
Agenda auto-merge setup
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Jan 30, 2025
1 parent 1b099c4 commit e6d82f8
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/wgutils-automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Agenda auto-merge

# First, enable branch protections, and in particular ensure the EasyCLA check is required.
# Then, uncomment the next 3 lines:
#on:
# pull_request_target:
# types: [synchronize, opened, reopened]

permissions:
contents: write
pull-requests: read
checks: read

jobs:
validate-and-merge:
if: ${{ github.event.pull_request.base.ref == 'main' }}
runs-on: ubuntu-latest

steps:
# SECURITY: it's critical we do not check out the source pull request!
- name: Checkout the main branch
uses: actions/checkout@v3
with:
ref: main

# We need wgutils to be installed
- run: yarn install

- name: Wait for checks to pass
env:
GH_TOKEN: ${{ github.token }}
run: |
# Give 15 seconds for any checks to register
sleep 15
# Wait for checks to pass
gh pr checks ${{ github.event.pull_request.number }} --fail-fast --watch --required 2>&1 || true
# Now get the result in JSON
CHECKS_OUTPUT="$(gh pr checks ${{ github.event.pull_request.number }} --required --json bucket --jq 'map(.bucket == "pass") | all' 2>&1 || true)"
if echo "$CHECKS_OUTPUT" | grep -q "no required checks reported"; then
echo "Not required: $CHECKS_OUTPUT"
elif [[ "$CHECKS_OUTPUT" == "true" ]]; then
echo "$CHECKS_OUTPUT"
else
echo "PR state failed? $CHECKS_OUTPUT"
exit 1
fi
- name: Automerge if wgutils approves
env:
GH_TOKEN: ${{ github.token }}
run: |
if yarn wgutils can-automerge "${{ github.event.pull_request.number }}" "${{ github.event.pull_request.head.sha }}"; then
gh pr merge "${{ github.event.pull_request.number }}" --squash --auto --match-head-commit "${{ github.event.pull_request.head.sha }}"
fi
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ GraphQL Foundation. To use this template you should:
- `nth`, `weekday`, `time` - when will your WG be? (e.g. 4th Thursday at 10:30am-12am would be `nth: 4, weekday: "Th", time: "10:30-12:00"`)
- generate your first month's agenda `yarn && yarn gen-agenda YYYY MM` (replacing YYYY MM with the meeting's year and month, e.g. `2025 01`)
- let @Benjie know the first meeting is scheduled and ask for the GraphQL Foundation calendar to be updated
- (optional) ask @Benjie or a TSC member to enable agenda auto-merge:
- set up branch protections on `main`, specifically requiring `EasyCLA` to pass (may require a PR to be raised to trigger EasyCLA the first time?)
- uncomment the block at the top of `.github/workflows/wgutils-automerge.yml`

In this README, items that need replacing are ALLCAPS and surrounded by
parenthesis. We've attempted to make as much of the text as possible generic so
Expand Down

0 comments on commit e6d82f8

Please sign in to comment.