Skip to content

Commit

Permalink
Add comment with links to deployed examples
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews committed Nov 15, 2024
1 parent 43fe5e3 commit 67a5832
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions .github/workflows/deploy_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,64 @@ jobs:
- name: Deploy Linearlite
working-directory: examples/linearlite
run: pnpm sst deploy --stage ${{ env.DEPLOY_ENV }}
run: |
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }}
if [ -f ".sst/outputs.json" ]; then
linearlite=$(jq -r '.website' .sst/outputs.json)
echo "linearlite=$linearlite" >> $GITHUB_ENV
else
echo "sst outputs file not found. Exiting."
exit 1
fi
- name: Deploy NextJs example
working-directory: examples/nextjs-example
run: pnpm sst deploy --stage ${{ env.DEPLOY_ENV }}
run: |
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }}
if [ -f ".sst/outputs.json" ]; then
nextjs=$(jq -r '.website' .sst/outputs.json)
echo "nextjs=$nextjs" >> $GITHUB_ENV
else
echo "sst outputs file not found. Exiting."
exit 1
fi
- name: Add comment to PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const linearlite = process.env.linearlite;
const nextjs = process.env.nextjs;
const commentBody = `## Examples
- linearlite: ${linearlite}
- nextjs: ${nextjs}
`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const existingComment = comments.find(comment => comment.user.login ==='github-actions[bot]' && comment.body.startsWith("## Examples"));
if (existingComment) {
// Update the existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: commentBody,
});
} else {
// Create a new comment if none exists
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: commentBody,
});
}

0 comments on commit 67a5832

Please sign in to comment.