Skip to content

Commit 4fffe28

Browse files
authored
Centralized some GitHub Actions (#128)
1 parent 2209eaa commit 4fffe28

File tree

7 files changed

+19
-711
lines changed

7 files changed

+19
-711
lines changed

.github/workflows/auto-assign.yml

Lines changed: 3 additions & 441 deletions
Large diffs are not rendered by default.

.github/workflows/issue-assigned.yml

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,8 @@
1212
name: Issue Assignment Workflow
1313
on:
1414
issues:
15-
types: ['assigned']
16-
permissions:
17-
contents: read
18-
issues: write
15+
types: ['assigned']
1916

2017
jobs:
2118
Remove-Unapproved-Label:
22-
name: Remove Unapproved Label when issue is assigned
23-
runs-on: ubuntu-latest
24-
steps:
25-
- uses: actions/github-script@v7
26-
with:
27-
script: |
28-
const { owner, repo } = context.repo;
29-
const issue_number = context.issue.number;
30-
const apiParams = {
31-
owner,
32-
repo,
33-
issue_number
34-
};
35-
36-
// Get current labels on the issue
37-
const { data: labelList } = await github.rest.issues.listLabelsOnIssue(apiParams);
38-
const unapprovedLabel = labelList.find(l =>
39-
l.name.toLowerCase().includes('unapprov') // matches 'unapproved' too
40-
);
41-
42-
// Remove unapproved label if it exists
43-
if (unapprovedLabel) {
44-
45-
try {
46-
await github.rest.issues.removeLabel({
47-
owner,
48-
repo,
49-
issue_number,
50-
name: unapprovedLabel.name,
51-
});
52-
} catch (err) {
53-
if (err.status !== 404) throw err;
54-
}
55-
}
19+
uses: PalisadoesFoundation/.github/.github/workflows/issue-assigned.yml@main

.github/workflows/issue-unassigned.yml

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,6 @@ on:
66

77
jobs:
88
add-unapproved-label:
9-
runs-on: ubuntu-latest
10-
11-
permissions:
12-
issues: write
13-
contents: read
14-
15-
steps:
16-
- name: Add unapproved label
17-
uses: actions/github-script@v7
18-
with:
19-
script: |
20-
const { owner, repo } = context.repo;
21-
const issue_number = context.issue.number;
22-
23-
try {
24-
// Get the complete issue object (includes ALL labels, no pagination issues)
25-
const { data: issue } = await github.rest.issues.get({
26-
owner,
27-
repo,
28-
issue_number
29-
});
30-
31-
// Check if the issue already has the 'unapproved' label (exact match)
32-
const hasUnapprovedLabel = issue.labels.some(
33-
label => label.name === 'unapproved'
34-
);
35-
36-
// Only add if it doesn't already have the label
37-
if (!hasUnapprovedLabel) {
38-
await github.rest.issues.addLabels({
39-
owner,
40-
repo,
41-
issue_number,
42-
labels: ['unapproved']
43-
});
44-
45-
console.log(`Added 'unapproved' label to issue #${issue_number}`);
46-
} else {
47-
console.log(`Issue #${issue_number} already has 'unapproved' label - skipping`);
48-
}
49-
} catch (error) {
50-
console.error(`Error processing issue #${issue_number}:`, error.message);
51-
throw error; // Re-throw to fail the workflow and alert maintainers
52-
}
9+
uses: PalisadoesFoundation/.github/.github/workflows/issue-unassigned.yml@main
10+
secrets:
11+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/issue.yml

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,9 @@
1-
##############################################################################
2-
##############################################################################
3-
#
4-
# NOTE!
5-
#
6-
# Please read the README.md file in this directory that defines what should
7-
# be placed in this file
8-
#
9-
##############################################################################
10-
##############################################################################
11-
121
name: Issue Workflow
132
on:
143
issues:
154
types: ['opened']
165
jobs:
17-
Opened-issue-label:
18-
name: Adding Issue Label
19-
runs-on: ubuntu-latest
20-
steps:
21-
- uses: actions/checkout@v4
22-
with:
23-
sparse-checkout: |
24-
.github/workflows/auto-label.json5
25-
sparse-checkout-cone-mode: false
26-
- uses: Renato66/auto-label@v3
27-
with:
28-
repo-token: ${{ secrets.GITHUB_TOKEN }}
29-
- uses: actions/github-script@v7
30-
env:
31-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
with:
33-
script: |
34-
const { owner, repo } = context.repo;
35-
const issue_number = context.issue.number;
36-
const apiParams = {
37-
owner,
38-
repo,
39-
issue_number
40-
};
41-
const labels = await github.rest.issues.listLabelsOnIssue(apiParams);
42-
if(labels.data.reduce((a, c)=>a||["dependencies"].includes(c.name), false))
43-
await github.rest.issues.addLabels({
44-
owner: context.repo.owner,
45-
repo: context.repo.repo,
46-
issue_number: context.issue.number,
47-
labels: ["good first issue", "security"]
48-
});
49-
else if(labels.data.reduce((a, c)=>a||["security", "ui/ux", "test", "ci/cd"].includes(c.name), false))
50-
await github.rest.issues.addLabels({
51-
owner: context.repo.owner,
52-
repo: context.repo.repo,
53-
issue_number: context.issue.number,
54-
labels: ["good first issue"]
55-
});
6+
Opened-issue-label:
7+
uses: PalisadoesFoundation/.github/.github/workflows/issue.yml@main
8+
secrets:
9+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pull-request-review.yml

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,4 @@ on:
66

77
jobs:
88
Check-CodeRabbit-Approval:
9-
name: Check CodeRabbit Approval
10-
runs-on: ubuntu-latest
11-
permissions:
12-
pull-requests: read
13-
steps:
14-
- name: Sleep for 30 seconds to make sure the review status propagates
15-
run: sleep 30s
16-
shell: bash
17-
- name: Check CodeRabbit approval using GitHub Script
18-
uses: actions/github-script@v7
19-
with:
20-
github-token: ${{ secrets.GITHUB_TOKEN }}
21-
script: |
22-
// List all reviews for the PR
23-
const { data: reviews } = await github.rest.pulls.listReviews({
24-
owner: context.repo.owner,
25-
repo: context.repo.repo,
26-
pull_number: context.payload.pull_request.number
27-
});
28-
29-
// Filter reviews that have a user login containing "coderabbit" (case-insensitive)
30-
// and exclude COMMENTED states.
31-
const codeRabbitReviews = reviews.filter(review =>
32-
(review.user.login.toLowerCase().includes('coderabbit') ||
33-
review.user.login.toLowerCase().includes('coderabbitai')) &&
34-
review.state !== 'COMMENTED'
35-
);
36-
37-
// Fail if no CodeRabbit reviews are found
38-
if (codeRabbitReviews.length === 0) {
39-
core.setFailed('ERROR: CodeRabbit has not reviewed this PR.');
40-
return;
41-
}
42-
43-
// Sort reviews by submitted_at date in descending order
44-
codeRabbitReviews.sort((a, b) => new Date(b.submitted_at) - new Date(a.submitted_at));
45-
const latestReview = codeRabbitReviews[0];
46-
47-
// Fail if the latest review from CodeRabbit is not "APPROVED"
48-
if (latestReview.state !== 'APPROVED') {
49-
core.setFailed('ERROR: CodeRabbit approval is required before merging this PR.');
50-
} else {
51-
console.log('Success: CodeRabbit has approved this PR.');
52-
}
9+
uses: PalisadoesFoundation/.github/.github/workflows/pull-request-review.yml@main
Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,10 @@
1-
##############################################################################
2-
##############################################################################
3-
#
4-
# NOTE!
5-
#
6-
# Please read the README.md file in this directory that defines what should
7-
# be placed in this file
8-
#
9-
##############################################################################
10-
##############################################################################
11-
121
name: PR Target Workflow
2+
133
on:
144
pull_request_target:
155

16-
# Required for arkid15r/check-pr-issue-action
17-
permissions:
18-
contents: read
19-
issues: read
20-
pull-requests: write
21-
226
jobs:
237
PR-Greeting:
24-
name: Pull Request Greeting
25-
runs-on: ubuntu-latest
26-
steps:
27-
- name: Add the PR Review Policy
28-
uses: thollander/actions-comment-pull-request@v3
29-
with:
30-
comment-tag: pr_review_policy
31-
message: |
32-
## Our Pull Request Approval Process
33-
34-
This PR will be reviewed according to our:
35-
36-
1. [Palisadoes Contributing Guidelines](https://developer.palisadoes.org/docs/contributor-guide/contributing)
37-
38-
2. [AI Usage Policy](https://developer.palisadoes.org/docs/contributor-guide/ai)
39-
40-
Your PR may be automatically closed if:
41-
42-
1. Our PR template isn't filled in correctly
43-
44-
1. [You haven't correctly linked your PR to an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue)
45-
46-
Thanks for contributing!
47-
48-
Check-PR-Issue:
49-
name: Check Correct PR Issue Assignment
50-
runs-on: ubuntu-latest
51-
needs: [PR-Greeting]
52-
steps:
53-
- uses: actions/checkout@v4
54-
- name: Check PR linked issue and assignee
55-
uses: arkid15r/check-pr-issue-action@0.1.3
56-
with:
57-
close_pr_on_failure: 'true'
58-
github_token: ${{ secrets.GITHUB_TOKEN }}
59-
no_assignee_message: 'The linked issue must be assigned to the PR author.'
60-
no_issue_message: 'The PR must be linked to an issue assigned to the PR author.'
61-
check_issue_reference: 'true'
62-
require_assignee: 'true'
63-
# List of usernames who can create PRs without having an assigned issue
64-
skip_users_file_path: '.github/workflows/config/check-pr-issue-skip-usernames.txt'
8+
uses: PalisadoesFoundation/.github/.github/workflows/pr-target-policy.yml@main
9+
secrets:
10+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/stale.yml

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,8 @@
1-
##############################################################################
2-
##############################################################################
3-
#
4-
# NOTE!
5-
#
6-
# Please read the README.md file in this directory that defines what should
7-
# be placed in this file
8-
#
9-
##############################################################################
10-
##############################################################################
11-
121
name: Mark stale issues and pull requests
132

143
on:
154
schedule:
16-
- cron: "0 0 * * *"
17-
18-
permissions:
19-
issues: write
20-
pull-requests: write
21-
5+
- cron: "*/20 0 * * *"
226
jobs:
237
stale:
24-
name: Process Stale Issues and PRs
25-
runs-on: ubuntu-latest
26-
steps:
27-
- uses: actions/stale@v9
28-
with:
29-
repo-token: ${{ secrets.GITHUB_TOKEN }}
30-
stale-issue-message: 'This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.'
31-
stale-pr-message: 'This pull request did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please verify it has no conflicts with the develop branch and rebase if needed. Mention it now if you need help or give permission to other people to finish your work.'
32-
close-issue-message: 'This issue did not get any activity in the past 180 days and thus has been closed. Please check if the newest release or develop branch has it fixed. Please, create a new issue if the issue is not fixed.'
33-
close-pr-message: 'This pull request did not get any activity in the past 180 days and thus has been closed.'
34-
stale-issue-label: 'no-issue-activity'
35-
stale-pr-label: 'no-pr-activity'
36-
days-before-stale: 7
37-
days-before-close: 180
38-
remove-stale-when-updated: true
39-
exempt-all-milestones: true
40-
exempt-pr-labels: 'wip'
41-
exempt-issue-labels: 'wip'
42-
operations-per-run: 30
8+
uses: PalisadoesFoundation/.github/.github/workflows/stale.yml@main

0 commit comments

Comments
 (0)