|
11 | 11 | type: string |
12 | 12 |
|
13 | 13 | # Prevent parallel runs for the same issue |
| 14 | +# When both 'opened' and 'labeled' events fire, cancel the older run |
14 | 15 | concurrency: |
15 | 16 | group: enhance-feature-request-${{ github.event.issue.number || inputs.issue_number }} |
16 | | - cancel-in-progress: false |
| 17 | + cancel-in-progress: true |
17 | 18 |
|
18 | 19 | permissions: |
19 | 20 | issues: write |
|
27 | 28 | has_enhancement: ${{ steps.check.outputs.has_enhancement }} |
28 | 29 | already_enhanced: ${{ steps.check.outputs.already_enhanced }} |
29 | 30 | issue_number: ${{ steps.set_issue.outputs.issue_number }} |
| 31 | + should_skip: ${{ steps.skip-opened.outputs.skip }} |
30 | 32 | steps: |
31 | 33 | - name: Set issue number |
32 | 34 | id: set_issue |
|
37 | 39 | echo "issue_number=${{ github.event.issue.number }}" >> "$GITHUB_OUTPUT" |
38 | 40 | fi |
39 | 41 |
|
| 42 | + - name: Check if opened event should be skipped |
| 43 | + id: skip-opened |
| 44 | + env: |
| 45 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + ISSUE_NUMBER: ${{ github.event.issue.number }} |
| 47 | + run: | |
| 48 | + # Default to not skipping (for labeled events and workflow_dispatch) |
| 49 | + SKIP_VALUE="false" |
| 50 | + |
| 51 | + # If issue is opened with enhancement label already present, |
| 52 | + # skip this run (labeled event will handle it to avoid duplicate runs) |
| 53 | + if [ "${{ github.event_name }}" = "issues" ] && [ "${{ github.event.action }}" = "opened" ]; then |
| 54 | + ISSUE_JSON=$(curl -s \ |
| 55 | + -H "Authorization: token $GITHUB_TOKEN" \ |
| 56 | + -H "Accept: application/vnd.github+json" \ |
| 57 | + "https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER") |
| 58 | + LABELS=$(echo "$ISSUE_JSON" | jq -r '.labels[].name' | tr '\n' ' ') |
| 59 | + if echo "$LABELS" | grep -qw "enhancement"; then |
| 60 | + echo "⚠️ Issue opened with enhancement label already present - skipping (labeled event will handle it)" |
| 61 | + SKIP_VALUE="true" |
| 62 | + fi |
| 63 | + fi |
| 64 | + echo "skip=$SKIP_VALUE" >> "$GITHUB_OUTPUT" |
| 65 | +
|
40 | 66 | - name: Fetch and check issue |
41 | 67 | id: check |
42 | 68 | env: |
|
79 | 105 | preprocess: |
80 | 106 | runs-on: ubuntu-latest |
81 | 107 | needs: check-label |
82 | | - if: needs.check-label.outputs.has_enhancement == 'true' && needs.check-label.outputs.already_enhanced == 'false' |
| 108 | + if: needs.check-label.outputs.should_skip != 'true' && needs.check-label.outputs.has_enhancement == 'true' && needs.check-label.outputs.already_enhanced == 'false' |
83 | 109 | outputs: |
84 | 110 | enhanced_task: ${{ steps.preprocess.outputs.enhanced_task }} |
85 | 111 | issue_title: ${{ steps.fetch.outputs.issue_title }} |
|
0 commit comments