| Josh Bleecher Snyder | efda396 | 2025-04-30 13:09:42 -0700 | [diff] [blame] | 1 | # This is a copy of queue-main.yml, but with a different branch pattern. |
| 2 | # It does not push the result anywhere; it logs instead. |
| 3 | # It is meant for people changing how the commit queue works: |
| 4 | # You can hack on the workflows, push to queue-dev-$USER, and iterate. |
| 5 | # Please keep this file in sync with queue-main.yml. |
| 6 | |
| 7 | name: Dev Commit Queue |
| 8 | on: |
| 9 | push: |
| 10 | branches: |
| 11 | - "queue-dev-*" |
| 12 | |
| 13 | permissions: read-all |
| 14 | |
| 15 | jobs: |
| 16 | formatting: |
| 17 | uses: ./.github/workflows/formatting.yml |
| 18 | permissions: |
| 19 | contents: write |
| 20 | with: |
| 21 | auto_fix: true |
| 22 | |
| 23 | go-test: |
| 24 | needs: [formatting] |
| 25 | uses: ./.github/workflows/go_test.yml |
| 26 | permissions: read-all |
| Josh Bleecher Snyder | 936ba62 | 2025-04-30 20:53:21 +0000 | [diff] [blame] | 27 | with: |
| 28 | ref: ${{ needs.formatting.outputs.commit_sha }} |
| Josh Bleecher Snyder | efda396 | 2025-04-30 13:09:42 -0700 | [diff] [blame] | 29 | |
| 30 | ui-test: |
| 31 | needs: [formatting] |
| 32 | uses: ./.github/workflows/webui_test.yml |
| 33 | permissions: read-all |
| Josh Bleecher Snyder | 936ba62 | 2025-04-30 20:53:21 +0000 | [diff] [blame] | 34 | with: |
| 35 | ref: ${{ needs.formatting.outputs.commit_sha }} |
| Josh Bleecher Snyder | efda396 | 2025-04-30 13:09:42 -0700 | [diff] [blame] | 36 | |
| 37 | push-to-main: |
| 38 | runs-on: ubuntu-latest |
| 39 | needs: [go-test, ui-test, formatting] |
| 40 | permissions: |
| 41 | contents: write |
| 42 | steps: |
| 43 | - uses: actions/checkout@v4 |
| 44 | with: |
| 45 | fetch-depth: 0 |
| 46 | |
| 47 | - name: Push to main |
| Josh Bleecher Snyder | 6e46360 | 2025-05-28 18:10:59 +0000 | [diff] [blame] | 48 | id: push |
| Josh Bleecher Snyder | efda396 | 2025-04-30 13:09:42 -0700 | [diff] [blame] | 49 | run: | |
| 50 | COMMIT_TO_PUSH="HEAD" |
| 51 | if [[ "${{ needs.formatting.outputs.commit_sha }}" != "" ]]; then |
| 52 | echo "Using formatted commit: ${{ needs.formatting.outputs.commit_sha }}" |
| 53 | COMMIT_TO_PUSH="${{ needs.formatting.outputs.commit_sha }}" |
| 54 | fi |
| 55 | |
| Josh Bleecher Snyder | 6e46360 | 2025-05-28 18:10:59 +0000 | [diff] [blame] | 56 | # Get the actual commit SHA that we're pushing |
| 57 | COMMIT_SHA=$(git rev-parse "${COMMIT_TO_PUSH}") |
| 58 | echo "commit_sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT |
| 59 | |
| Josh Bleecher Snyder | 837699b | 2025-05-28 18:58:17 +0000 | [diff] [blame] | 60 | # Get the list of commits that would be pushed (in chronological order) |
| 61 | COMMITS_TO_NOTIFY=$(git log origin/main.."${COMMIT_TO_PUSH}" --reverse --format="%H" | tr '\n' ' ') |
| 62 | echo "commits_to_notify=${COMMITS_TO_NOTIFY}" >> $GITHUB_OUTPUT |
| 63 | echo "Commits that would be pushed and notified: ${COMMITS_TO_NOTIFY}" |
| 64 | |
| Josh Bleecher Snyder | efda396 | 2025-04-30 13:09:42 -0700 | [diff] [blame] | 65 | echo "Would push to main: ${COMMIT_TO_PUSH}" |
| 66 | env: |
| 67 | GITHUB_TOKEN: ${{ github.token }} |
| Josh Bleecher Snyder | 6e46360 | 2025-05-28 18:10:59 +0000 | [diff] [blame] | 68 | |
| Josh Bleecher Snyder | 837699b | 2025-05-28 18:58:17 +0000 | [diff] [blame] | 69 | - name: Send Discord notifications for all commits that would be pushed |
| Josh Bleecher Snyder | 6e46360 | 2025-05-28 18:10:59 +0000 | [diff] [blame] | 70 | if: success() |
| 71 | env: |
| 72 | DISCORD_WEBHOOK_FOR_COMMITS: ${{ secrets.DISCORD_WEBHOOK_FOR_COMMITS }} |
| Josh Bleecher Snyder | 837699b | 2025-05-28 18:58:17 +0000 | [diff] [blame] | 73 | run: | |
| 74 | COMMITS="${{ steps.push.outputs.commits_to_notify }}" |
| 75 | if [[ -z "$COMMITS" ]]; then |
| 76 | echo "No commits to notify about" |
| 77 | exit 0 |
| 78 | fi |
| 79 | |
| 80 | echo "Sending Discord notifications for commits that would be pushed: $COMMITS" |
| 81 | for commit_sha in $COMMITS; do |
| 82 | echo "Sending notification for commit: $commit_sha" |
| 83 | git checkout "$commit_sha" |
| 84 | GITHUB_SHA="$commit_sha" python3 .github/scripts/discord_notify.py |
| 85 | done |