Skip to content

Commit

Permalink
consolidate steps
Browse files Browse the repository at this point in the history
  • Loading branch information
rezrah committed Dec 4, 2024
1 parent 67ddb36 commit 427d3d7
Showing 1 changed file with 32 additions and 34 deletions.
66 changes: 32 additions & 34 deletions .github/workflows/new_release_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,44 +51,42 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prs = await github.rest.pulls.list({
owner: 'primer',
repo: 'brand',
state: 'closed',
sort: 'updated',
direction: 'desc',
per_page: 1,
head: 'changeset-release/main'
owner: "primer",
repo: "brand",
state: "closed",
sort: "updated",
direction: "desc",
});
if (prs.data.length === 0) {
core.setFailed('No closed PR found with branch changeset-release/main.');
const targetPr = prs.data.find(
(pr) => pr.head.ref === "changeset-release/main"
);
if (!targetPr) {
console.error("No closed PR found with branch changeset-release/main.");
process.exit(1);
} else {
const pr = prs.data[0];
console.log('Found PR:', pr);
const comments = await github.rest.issues.listComments({
owner: 'primer',
repo: 'brand',
issue_number: pr.number
owner: "primer",
repo: "brand",
issue_number: targetPr.number,
});
const filteredComments = comments.data.filter(comment => comment.user.login !== 'github-actions');
const filteredComments = comments.data.filter(
(comment) =>
comment.user.login !== "github-actions[bot]" &&
comment.user.login !== "changeset-bot[bot]"
);
console.log('Filtered comments:', filteredComments);
core.setOutput('comments', JSON.stringify(filteredComments));
}
- name: Post comments to issue
if: success()
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const comments = JSON.parse('${{ steps.get_pr_comments.outputs.comments }}');
const issue_number = ${{ steps.created-issue.outputs.number }};
console.log('Posting comments to issue number:', issue_number);
for (const comment of comments) {
console.log('Posting comment:', comment.body);
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: comment.body
});
// post comments to issue
const issue_number = ${{ steps.created-issue.outputs.number }};
console.log('Posting comments to issue number:', issue_number);
for (const comment of filteredComments) {
await github.rest.issues.createComment({
owner: 'primer',
repo: 'brand-releases',
issue_number: issue_number,
body: comment.body
});
}
}

0 comments on commit 427d3d7

Please sign in to comment.