Skip to content

Commit f31713e

Browse files
kopporGuilhermeRibeiroPereira
authored andcommitted
Move issues on PR activity (JabRef#12690)
1 parent 9ee58f9 commit f31713e

File tree

4 files changed

+145
-1
lines changed

4 files changed

+145
-1
lines changed

.github/ghprcomment.yml

+32
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,35 @@
4949
Commits will be lost, comments on commits will loose their context.
5050
This makes it harder to review.
5151
In the end, all commits will be [squashed](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-commits) either way before being merged into the `main`` branch.
52+
- jobName: move_issue
53+
message: |
54+
Your pull request needs to link an issue.
55+
56+
To ease organizational workflows, please link this pull-request to the issue with syntax as described in <https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue>:
57+
58+
> <h2 id="linking-a-pull-request-to-an-issue-using-a-keyword">Linking a pull request to an issue using a keyword</h2>
59+
> <p>You can link a pull request to an issue by using a supported keyword
60+
> in the pull request's description or in a commit message. The pull
61+
> request <strong>must be</strong> on the default branch.</p>
62+
> <ul>
63+
> <li>close</li>
64+
> <li>closes</li>
65+
> <li>closed</li>
66+
> <li>fix</li>
67+
> <li>fixes</li>
68+
> <li>fixed</li>
69+
> <li>resolve</li>
70+
> <li>resolves</li>
71+
> <li>resolved</li>
72+
> </ul>
73+
> <p>If you use a keyword to reference a pull request comment in another
74+
> pull request, the pull requests will be linked. Merging the referencing
75+
> pull request also closes the referenced pull request.</p>
76+
> <p>The syntax for closing keywords depends on whether the issue is in the same repository as the pull request.</p>
77+
78+
### Examples
79+
80+
- ✅ `Fixes #xyz` links pull-request to issue. Merging the PR will close the issue.
81+
- ✅ `Fixes https://github.com/JabRef/jabref/issues/xyz` links pull-request to issue. Merging the PR will close the issue.
82+
- ✅ `Fixes https://github.com/Koppor/jabref/issues/xyz` links pull-request to issue. Merging the PR will close the issue.
83+
- ❌ `Fixes [#xyz](https://github.com/JabRef/jabref/issues/xyz)` links pull-request to issue. Merging the PR will **NOT** close the issue.

.github/workflows/on-pr-closed.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Mark issue as available
2+
3+
on:
4+
pull_request_target:
5+
types: [ closed ]
6+
7+
jobs:
8+
unassign_issue:
9+
runs-on: ubuntu-latest
10+
if: github.event.action == 'closed' && !github.event.pull_request.merged
11+
permissions:
12+
contents: read
13+
issues: write
14+
steps:
15+
- name: Determine issue number
16+
id: get_issue_number
17+
uses: koppor/ticket-check-action@add-output
18+
with:
19+
token: ${{ secrets.GITHUB_TOKEN }}
20+
ticketLink: 'https://github.com/:owner/:repo/issues/%ticketNumber%'
21+
ticketPrefix: '#'
22+
titleRegex: '^#(?<ticketNumber>\d+)'
23+
branchRegex: '^(?<ticketNumber>\d+)'
24+
bodyRegex: '#(?<ticketNumber>\d+)'
25+
bodyURLRegex: 'http(s?):\/\/(github.com)(\/:owner)(\/:repo)(\/issues)\/(?<ticketNumber>\d+)'
26+
outputOnly: true
27+
- name: Move issue to "Free to take" in "Good First Issues"
28+
uses: m7kvqbe1/github-action-move-issues/@add-issue-parameter
29+
with:
30+
github-token: ${{ secrets.GH_TOKEN_ACTION_MOVE_ISSUE }}
31+
project-url: "https://github.com/orgs/JabRef/projects/5"
32+
target-labels: "📍 Assigned"
33+
target-column: "Free to take"
34+
ignored-columns: ""
35+
default-column: "Free to take"
36+
issue-number: ${{ steps.get_issue_number.outputs.ticketNumber }}
37+
skip-if-not-in-project: true
38+
- name: Move issue to "Free to take" in "Candidates for University Projects"
39+
uses: m7kvqbe1/github-action-move-issues/@add-issue-parameter
40+
with:
41+
github-token: ${{ secrets.GH_TOKEN_ACTION_MOVE_ISSUE }}
42+
project-url: "https://github.com/orgs/JabRef/projects/3"
43+
target-labels: "📍 Assigned"
44+
target-column: "Free to take"
45+
ignored-columns: ""
46+
default-column: "Free to take"
47+
issue-number: ${{ steps.get_issue_number.outputs.ticketNumber }}
48+
skip-if-not-in-project: true
49+
- uses: actions/checkout@v4
50+
- name: Remove assigned status
51+
run : gh issue edit ${{ steps.get_issue_number.outputs.ticketNumber }} --remove-assignee ${{ github.event.pull_request.user.login }}
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
- name: Remove assigned label
55+
run : gh issue edit ${{ steps.get_issue_number.outputs.ticketNumber }} --remove-label "📍 Assigned"
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/on-pr-opened.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Mark issue as in progress
2+
3+
on:
4+
# _target is required
5+
pull_request_target:
6+
7+
jobs:
8+
move_issue:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
steps:
13+
- name: Determine issue number
14+
id: get_issue_number
15+
uses: koppor/ticket-check-action@add-output
16+
with:
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
ticketLink: 'https://github.com/:owner/:repo/issues/%ticketNumber%'
19+
ticketPrefix: '#'
20+
titleRegex: '^#(?<ticketNumber>\d+)'
21+
branchRegex: '^(?<ticketNumber>\d+)'
22+
bodyRegex: '#(?<ticketNumber>\d+)'
23+
bodyURLRegex: 'http(s?):\/\/(github.com)(\/:owner)(\/:repo)(\/issues)\/(?<ticketNumber>\d+)'
24+
outputOnly: true
25+
- name: Move issue to "In Progress" in "Good First Issues"
26+
uses: m7kvqbe1/github-action-move-issues/@add-issue-parameter
27+
with:
28+
github-token: ${{ secrets.GH_TOKEN_ACTION_MOVE_ISSUE }}
29+
project-url: "https://github.com/orgs/JabRef/projects/5"
30+
target-labels: "📍 Assigned"
31+
target-column: "In Progress"
32+
ignored-columns: ""
33+
default-column: "In Progress"
34+
issue-number: ${{ steps.get_issue_number.outputs.ticketNumber }}
35+
skip-if-not-in-project: true
36+
- name: Move issue to "In Progress" in "Candidates for University Projects"
37+
uses: m7kvqbe1/github-action-move-issues/@add-issue-parameter
38+
with:
39+
github-token: ${{ secrets.GH_TOKEN_ACTION_MOVE_ISSUE }}
40+
project-url: "https://github.com/orgs/JabRef/projects/7"
41+
target-labels: "📍 Assigned"
42+
target-column: "In Progress"
43+
ignored-columns: ""
44+
default-column: "In Progress"
45+
issue-number: ${{ steps.get_issue_number.outputs.ticketNumber }}
46+
skip-if-not-in-project: true
47+
upload-pr-number:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Create pr_number.txt
51+
run: echo "${{ github.event.number }}" > pr_number.txt
52+
- uses: actions/upload-artifact@v4
53+
with:
54+
name: pr_number
55+
path: pr_number.txt

.github/workflows/pr-comment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: Comment on PR
77

88
on:
99
workflow_run:
10-
workflows: ["Tests"]
10+
workflows: ["Tests", "Mark issue as in progress"]
1111
types:
1212
- completed
1313

0 commit comments

Comments
 (0)