|
6 | 6 | # default: opened, synchronize, reopened |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - determine_issue_number: |
10 | | - name: Determine issue number |
11 | | - runs-on: ubuntu-latest |
12 | | - if: > |
13 | | - (github.repository == 'JabRef/jabref') && |
14 | | - (github.event.pull_request.head.repo.full_name != 'JabRef/jabref') && |
15 | | - !( |
16 | | - (github.event.pull_request.user.login == 'dependabot[bot]') || (github.event.pull_request.user.login == 'renovate-bot') || |
17 | | - ( |
18 | | - startsWith(github.event.pull_request.title, '[Bot] ') || |
19 | | - startsWith(github.event.pull_request.title, 'Bump ') || |
20 | | - startsWith(github.event.pull_request.title, 'New Crowdin updates') || |
21 | | - startsWith(github.event.pull_request.title, 'Update Gradle Wrapper from') |
22 | | - ) |
23 | | - ) |
24 | | - permissions: |
25 | | - contents: read |
26 | | - outputs: |
27 | | - issue_number: ${{ steps.get_issue_number.outputs.ticketNumber }} |
28 | | - steps: |
29 | | - - name: echo PR data |
30 | | - run: | |
31 | | - echo "PR Number: ${{ github.event.pull_request.number }}" |
32 | | - echo "PR URL: ${{ github.event.pull_request.html_url }}" |
33 | | - cat <<EOF |
34 | | - PR Body: |
35 | | - ${{ github.event.pull_request.body }} |
36 | | - EOF |
37 | | - - name: Determine issue number |
38 | | - id: get_issue_number |
39 | | - uses: koppor/ticket-check-action@add-output |
40 | | - with: |
41 | | - token: ${{ secrets.GITHUB_TOKEN }} |
42 | | - ticketLink: 'https://github.com/JabRef/jabref/issues/%ticketNumber%' |
43 | | - ticketPrefix: '#' |
44 | | - titleRegex: '^#(?<ticketNumber>\d+)' |
45 | | - branchRegex: '^(?<ticketNumber>\d+)' |
46 | | - # Matches GitHub's closes/fixes/resolves #{number}, but does not match our example `Closes #13109` in PULL_REQUEST_TEMPLATE |
47 | | - # Also matches URLs that are wrapped in `<>`. |
48 | | - bodyRegex: '(?<action>fixes|closes|resolves|refs)\s+<?(?:https?:\/\/github\.com\/JabRef\/jabref\/issues\/)?#?(?<ticketNumber>(?!13109\b)\d+)>?' |
49 | | - bodyRegexFlags: 'i' |
50 | | - outputOnly: true |
51 | | - - run: echo "${{ steps.get_issue_number.outputs.ticketNumber }}" |
52 | | - - name: Issue number present |
53 | | - if: steps.get_issue_number.outputs.ticketNumber == '-1' |
54 | | - run: | |
55 | | - echo "No valid ticket number found!" |
56 | | - exit 1 |
57 | | - move_issue: |
58 | | - name: Mark issue as in progress |
59 | | - # after determine_issue_number to ensure that there is only one failure because of no ticket number |
60 | | - needs: determine_issue_number |
61 | | - runs-on: ubuntu-latest |
62 | | - permissions: |
63 | | - issues: write |
64 | | - steps: |
65 | | - - name: Move issue to "In Progress" in "Good First Issues" |
66 | | - uses: m7kvqbe1/github-action-move-issues/@main |
67 | | - with: |
68 | | - github-token: ${{ secrets.GH_TOKEN_ACTION_MOVE_ISSUE }} |
69 | | - project-url: "https://github.com/orgs/JabRef/projects/5" |
70 | | - target-labels: "📍 Assigned" |
71 | | - target-column: "In Progress" |
72 | | - ignored-columns: "" |
73 | | - default-column: "In Progress" |
74 | | - issue-number: ${{ needs.determine_issue_number.outputs.issue_number }} |
75 | | - skip-if-not-in-project: true |
76 | | - - name: Move issue to "In Progress" in "Candidates for University Projects" |
77 | | - uses: m7kvqbe1/github-action-move-issues/@main |
78 | | - with: |
79 | | - github-token: ${{ secrets.GH_TOKEN_ACTION_MOVE_ISSUE }} |
80 | | - project-url: "https://github.com/orgs/JabRef/projects/3" |
81 | | - target-labels: "📍 Assigned" |
82 | | - target-column: "In Progress" |
83 | | - ignored-columns: "" |
84 | | - default-column: "In Progress" |
85 | | - issue-number: ${{ needs.determine_issue_number.outputs.issue_number }} |
86 | | - skip-if-not-in-project: true |
87 | | - ensure_assignment: |
88 | | - name: Ensure that contributor is assigned (fails if not commented on issue) |
89 | | - if: github.event.pull_request.head.repo.full_name != 'JabRef/jabref' |
90 | | - # after determine_issue_number to ensure that there is only one failure because of no ticket number |
91 | | - needs: determine_issue_number |
92 | | - runs-on: ubuntu-latest |
93 | | - permissions: |
94 | | - issues: write |
95 | | - steps: |
96 | | - - uses: actions/checkout@v5 |
97 | | - with: |
98 | | - show-progress: 'false' |
99 | | - - name: Assign PR creator to issue |
100 | | - run: | |
101 | | - set -e |
102 | | -
|
103 | | - echo "Updating issue '${{ needs.determine_issue_number.outputs.issue_number }}'" |
104 | | -
|
105 | | - # "gh issue edit" cannot be used - workaround found at https://github.com/cli/cli/issues/9620#issuecomment-2703135049 |
106 | | -
|
107 | | - ASSIGNEES=$(gh api /repos/JabRef/jabref/issues/${{ needs.determine_issue_number.outputs.issue_number }} --jq '[.assignees[].login]') |
108 | | -
|
109 | | - # Check if the user is already assigned |
110 | | - if echo "$ASSIGNEES" | jq -e '. | index("${{ github.event.pull_request.user.login }}")' >/dev/null; then |
111 | | - echo "User '${{ github.event.pull_request.user.login }}' is already an assignee. No update needed." |
112 | | - echo "Debug: $ASSIGNEES" |
113 | | - exit 0 |
114 | | - fi |
115 | | -
|
116 | | - # Append the new assignee |
117 | | - UPDATED_ASSIGNEES=$(echo "$ASSIGNEES" | jq --arg new "${{ github.event.pull_request.user.login }}" '. + [$new]') |
118 | | -
|
119 | | - LABELS=$(gh api repos/${{ github.repository }}/issues/${{ needs.determine_issue_number.outputs.issue_number }}/labels --jq '.[].name') |
120 | | - LABEL=$(echo "$LABELS" | grep -E '^good (first|second|third|forth) issue$' || true) |
121 | | - if [ -n "$LABEL" ]; then |
122 | | - echo "✅ Found label: $LABEL" |
123 | | - SILENT=false |
124 | | - # Apply label |
125 | | - gh issue edit "${{ github.event.pull_request.number }}" --add-label "$LABEL" |
126 | | - else |
127 | | - echo "🚫 Silent fail if not possible to add assignee" |
128 | | - SILENT=true |
129 | | - fi |
130 | | -
|
131 | | - # Update issue with the new assignee list |
132 | | - echo "Updating issue #${{ needs.determine_issue_number.outputs.issue_number }} updated with assignees: $UPDATED_ASSIGNEES..." |
133 | | - if [ "$SILENT" = true ]; then |
134 | | - gh api -X PATCH /repos/JabRef/jabref/issues/${{ needs.determine_issue_number.outputs.issue_number }} --input <(echo "{\"assignees\": $UPDATED_ASSIGNEES}") || true |
135 | | - else |
136 | | - gh api -X PATCH /repos/JabRef/jabref/issues/${{ needs.determine_issue_number.outputs.issue_number }} --input <(echo "{\"assignees\": $UPDATED_ASSIGNEES}") |
137 | | - fi |
138 | | - env: |
139 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
140 | | - - name: Add label "📌 Pinned" |
141 | | - run: gh issue edit ${{ needs.determine_issue_number.outputs.issue_number }} --add-label "📌 Pinned" |
142 | | - env: |
143 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
144 | 9 | conflicts_with_target: |
145 | 10 | if: github.repository == 'JabRef/jabref' |
146 | 11 | name: Conflicts with target branch |
|
0 commit comments