Skip to content

Commit

Permalink
{CI} Add ccoa announcement (#30438)
Browse files Browse the repository at this point in the history
* Create CCOA.yml

* Update CCOA.yml

* Update CCOA.yml

* Update CCOA.yml
  • Loading branch information
wangzelin007 authored Nov 29, 2024
1 parent a4eb750 commit d1ddaea
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/CCOA.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CCOA

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

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: 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("⚠️**Your changes in this PR will be released on Jan 14, 2025 due to CCOA (extend to Jan 6, 2025)**")
);
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: "⚠️**Your changes in this PR will be released on Jan 14, 2025 due to CCOA (extend to Jan 6, 2025)**",
});
}

0 comments on commit d1ddaea

Please sign in to comment.