Skip to content

Commit ab3c71a

Browse files
committed
Create CCOA.yml
1 parent d1a5844 commit ab3c71a

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/CCOA.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: CCOA
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- reopened
8+
9+
permissions:
10+
pull-requests: write
11+
12+
jobs:
13+
add_label_and_comment:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check current date securely
18+
id: date_check
19+
run: |
20+
# Define the block date (Jan 7, 2025)
21+
BLOCK_DATE=$(date -d "2025-01-07" +%s)
22+
23+
# Get the current date in seconds
24+
CURRENT_DATE=$(date +%s)
25+
26+
# Validate the dates and safely output the result
27+
if [ "$CURRENT_DATE" -lt "$BLOCK_DATE" ]; then
28+
echo "continue=true" >> "$GITHUB_OUTPUT"
29+
else
30+
echo "continue=false" >> "$GITHUB_OUTPUT"
31+
fi
32+
33+
- name: Add do-not-merge label
34+
if: steps.date_check.outputs.continue == 'true'
35+
uses: actions-ecosystem/action-add-labels@v1
36+
with:
37+
github_token: ${{ secrets.GITHUB_TOKEN }}
38+
labels: do-not-merge
39+
40+
- name: Comment on PR
41+
if: steps.date_check.outputs.continue == 'true'
42+
uses: actions/github-script@v7
43+
with:
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
script: |
46+
// Fetch existing comments
47+
const comments = await github.rest.issues.listComments({
48+
owner: context.repo.owner,
49+
repo: context.repo.repo,
50+
issue_number: context.issue.number,
51+
});
52+
53+
// Check if the specific comment already exists
54+
const existingComment = comments.data.find(comment =>
55+
comment.body.includes("🚫All pull requests will be blocked to merge until Jan 6, 2025 due to CCOA")
56+
);
57+
58+
if (existingComment) {
59+
console.log("Comment already exists. Skipping...");
60+
} else {
61+
console.log("No comment found. Adding a new one...");
62+
// Add a new comment
63+
await github.rest.issues.createComment({
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
issue_number: context.issue.number,
67+
body: "🚫All pull requests will be blocked to merge until Jan 6, 2025 due to CCOA",
68+
});
69+
}

0 commit comments

Comments
 (0)