Skip to content

Commit

Permalink
Update changeset checker
Browse files Browse the repository at this point in the history
  • Loading branch information
JayaShakthi97 committed Mar 20, 2024
1 parent afb1319 commit de57482
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions .github/workflows/check-changeset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,40 @@ jobs:
- name: Extract PR Number Artifact
run: unzip pr-number.zip

- name: Get Authenticated User Info
- name: 💬 Remove Existing Changeset Comment
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ env.GH_TOKEN }}
script: |
const userInfo = await github.users.getAuthenticated();
console.log("Username:", userInfo.data.login);
const fs = require('fs');
const PR_NUMBER = Number(fs.readFileSync('./PR_NUMBER', 'utf8').trim());
const REPO_OWNER = context.repo.owner;
const REPO_NAME = context.repo.repo;
// Fetch all comments on the pull request.
const comments = await github.issues.listComments({
owner: REPO_OWNER,
repo: REPO_NAME,
issue_number: PR_NUMBER,
});
console.log("COMMENTS_URL: https://api.github.com/repos/" + REPO_NAME + "/issues/" + PR_NUMBER + "/comments");
for (const comment of comments.data) {
console.log("COMMENT_OWNER: " + comment.user.login);
// Identify the changeset comment by its heading.
if (comment.body.includes("🦋 Changeset detected") || comment.body.includes("⚠️ No Changeset found")) {
console.log("COMMENT_ID_TO_DELETE: " + comment.id);
// Remove the changeset comment using the comment ID.
await github.issues.deleteComment({
owner: REPO_OWNER,
repo: REPO_NAME,
comment_id: comment.id,
});
}
}
- name: 💬 Add Changeset Comment
uses: actions/[email protected]
Expand Down

0 comments on commit de57482

Please sign in to comment.