Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Cristina de Carvalho committed Nov 16, 2023
1 parent b9aeef4 commit b53f493
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions .github/workflows/push-to-external-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,35 @@ jobs:
publish_branch: ${{ steps.branch.outputs.branch }}
allow_empty_commit: true

- name: Generate Preview URL
id: preview_url
- name: Generate pull request comment
id: pr_comment
run: |
preview_url="https://headless-clone-git-${{ steps.branch.outputs.branch }}-thomaskn1.vercel.app"
echo "preview_url=${preview_url}" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" == "pull_request" ]; then
preview_url="https://headless-clone-git-${{ steps.branch.outputs.branch }}-thomaskn1.vercel.app"
echo "body=A preview URL is being deployed to test this PR. It should be live in a short moment: ${preview_url}" >> $GITHUB_OUTPUT
- name: Check Existing Comments
id: check-comments
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const existingComments = await github.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
const marker = ${{ steps.pr_comment.outputs.body }}
const existingComment = existingComments.data.find(comment => comment.body.includes(marker));
console.log(existingComment ? 'Existing comment found' : 'No existing comment found');
// Set an output to pass information to subsequent steps
console.log(`echo "existingCommentFound=${existingComment ? 'true' : 'false'}" >> $GITHUB_OUTPUT`);
console.log(`echo "existingCommentId=${existingComment ? existingComment.id : ''}" >> $GITHUB_OUTPUT`);
- name: Comment on Pull Request
if: steps.check-comments.outputs.existingCommentFound != 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -51,5 +73,5 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `A preview URL is being deployed to test this PR. It should be live in a short moment: ${{ steps.preview_url.outputs.preview_url }}`
body: `${{ steps.pr_comment.outputs.body }}`
});

0 comments on commit b53f493

Please sign in to comment.