diff --git a/.github/workflows/issues-updates-on-merge.yml b/.github/workflows/issues-updates-on-merge.yml new file mode 100644 index 000000000..a0f091c34 --- /dev/null +++ b/.github/workflows/issues-updates-on-merge.yml @@ -0,0 +1,39 @@ +name: 🎯 Update Issues on Push + +on: + push: + branches: + - staging + - release + +jobs: + # This runs commits to staging/release, reading the commit messages. Check `pr-auto-manager.yml`:`update-linked-issues` for PR-linked updates. + update-linked-issues: + name: Update Issues on Push + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + # Checkout + # https://github.com/marketplace/actions/checkout + uses: actions/checkout@v4 + + - name: Extract Linked Issues from Commit Message + id: extract_issues + run: | + ISSUES=$(git log -1 --pretty=%B | grep -oiE '(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved) #([0-9]+)' | awk '{print $2}' | tr -d '#' | jq -R -s -c 'split("\n")[:-1]') + echo "issues=$ISSUES" >> $GITHUB_ENV + + - name: Label Linked Issues + id: label_linked_issues + env: + GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + run: | + for ISSUE in $(echo $issues | jq -r '.[]'); do + echo "Updating issue #$ISSUE" + if [ "${{ github.ref }}" == "refs/heads/staging" ]; then + gh issue edit $ISSUE -R ${{ github.repository }} --add-label "✅ Done (staging)" + elif [ "${{ github.ref }}" == "refs/heads/release" ]; then + gh issue edit $ISSUE -R ${{ github.repository }} --add-label "✅ Done" + fi + done diff --git a/.github/workflows/pr-auto-manager.yml b/.github/workflows/pr-auto-manager.yml index 2120f2de5..35cfabd8c 100644 --- a/.github/workflows/pr-auto-manager.yml +++ b/.github/workflows/pr-auto-manager.yml @@ -7,21 +7,6 @@ on: types: [created] jobs: - check-merge-conflicts: - name: Check Merge Conflicts - runs-on: ubuntu-latest - - steps: - - name: Check Merge Conflicts - # Label Conflicting Pull Requests - # https://github.com/marketplace/actions/label-conflicting-pull-requests - uses: eps1lon/actions-label-merge-conflict@v3 - with: - dirtyLabel: '🚫 Merge Conflicts' - repoToken: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} - commentOnDirty: > - ⚠️ This PR has conflicts that need to be resolved before it can be merged. - label-by-size: name: Apply Label for PR Size runs-on: ubuntu-latest @@ -95,8 +80,10 @@ jobs: check-merge-blocking-labels: name: Check Merge Blocking Labels - needs: [check-merge-conflicts, label-by-branches] + needs: [label-by-branches, label-by-files] runs-on: ubuntu-latest + # Run, even if the previous jobs were skipped/failed + if: always() steps: - name: Check Merge Blocking @@ -108,7 +95,6 @@ jobs: script: | const prLabels = context.payload.pull_request.labels.map(label => label.name); const blockingLabels = [ - "🚫 Merge Conflicts", "⛔ Don't Merge", "🔨 Needs Work", "🔬 Needs Testing", @@ -138,8 +124,10 @@ jobs: write-auto-comments: name: Post PR Comments Based on Labels - needs: [check-merge-conflicts, label-by-size, label-by-branches, label-by-files, remove-stale-label] + needs: [label-by-size, label-by-branches, label-by-files] runs-on: ubuntu-latest + # Run, even if the previous jobs were skipped/failed + if: always() steps: - name: Checkout Repository @@ -155,13 +143,14 @@ jobs: config_file: .github/pr-auto-comments.yml github_token: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + # This runs on merged PRs to staging, reading the PR body and directly linked issues. Check `issues-updates-on-merge.yml`:`update-linked-issues` for commit-based updates. update-linked-issues: name: Update Issues on Staging Merge runs-on: ubuntu-latest if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'staging' steps: - - name: Extract Linked Issues + - name: Extract Linked Issues From PR Description id: extract_issues run: | ISSUES=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH" | grep -oiE '(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved) #([0-9]+)' | awk '{print $2}' | tr -d '#' | jq -R -s -c 'split("\n")[:-1]') diff --git a/.github/workflows/pr-check-merge-conflicts.yaml b/.github/workflows/pr-check-merge-conflicts.yaml new file mode 100644 index 000000000..553ef40c9 --- /dev/null +++ b/.github/workflows/pr-check-merge-conflicts.yaml @@ -0,0 +1,24 @@ +name: 🎯 Push Handler + +on: + # So that PRs touching the same files as the push are updated + push: + # So that the `dirtyLabel` is removed if conflicts are resolved + pull_request_target: + types: [synchronize] + +jobs: + check-merge-conflicts: + name: Check Merge Conflicts + runs-on: ubuntu-latest + + steps: + - name: Check Merge Conflicts + # Label Conflicting Pull Requests + # https://github.com/marketplace/actions/label-conflicting-pull-requests + uses: eps1lon/actions-label-merge-conflict@v3 + with: + dirtyLabel: '🚫 Merge Conflicts' + repoToken: ${{ secrets.BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + commentOnDirty: > + ⚠️ This PR has conflicts that need to be resolved before it can be merged.