Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{CI} Add ccoa announcement #8352

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/CCOA.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CCOA

on:
pull_request_target:
types:
- opened
- reopened
branches:
- main

permissions:
pull-requests: write

jobs:
add_label_and_comment:
runs-on: ubuntu-latest

steps:
- name: Check current date securely
id: date_check
run: |
# Define the block date (Jan 7, 2025)
BLOCK_DATE=$(date -d "2025-01-07" +%s)

# Get the current date in seconds
CURRENT_DATE=$(date +%s)

# Validate the dates and safely output the result
if [ "$CURRENT_DATE" -lt "$BLOCK_DATE" ]; then
echo "continue=true" >> "$GITHUB_OUTPUT"
else
echo "continue=false" >> "$GITHUB_OUTPUT"
fi

- name: Add do-not-merge label
if: steps.date_check.outputs.continue == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ["do-not-merge"],
})

- name: Comment on PR
if: steps.date_check.outputs.continue == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Fetch existing comments
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

// Check if the specific comment already exists
const existingComment = comments.data.find(comment =>
comment.body.includes("🚫All pull requests will be blocked to merge until Jan 6, 2025 due to CCOA")
);

if (existingComment) {
console.log("Comment already exists. Skipping...");
} else {
console.log("No comment found. Adding a new one...");
// Add a new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: "🚫All pull requests will be blocked to merge until Jan 6, 2025 due to CCOA",
});
}
Loading