Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 committed Sep 25, 2024
1 parent e073651 commit 7d62b07
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/preview-link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
permissions:
contents: read
pull-requests: write
checks: write # Added permission for creating check runs
checks: write # Ensure this permission is set

jobs:
comment-deployment-link:
Expand Down Expand Up @@ -128,25 +128,25 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const deploymentUrl = `🚀 Deployment available at: [${{ steps.vercel_url.outputs.deployment_url }}](${{ steps.vercel_url.outputs.deployment_url }})`;
const links = `Here are the direct links to the updated files:\n${{ steps.links.outputs.links }}`;
const summary = `${deploymentUrl}\n\n${links}`;
// Access octokit.rest instead of github
const checkRuns = await octokit.rest.checks.listForRef({
// Access github.rest instead of octokit
const checkRuns = await github.rest.checks.listForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.payload.pull_request.head.sha,
});
const existingCheckRun = checkRuns.data.check_runs.find(
(run) => run.name === 'Vercel Deployment Preview'
);
if (existingCheckRun) {
// Update the existing check run
await octokit.rest.checks.update({
await github.rest.checks.update({
owner: context.repo.owner,
repo: context.repo.repo,
check_run_id: existingCheckRun.id,
Expand All @@ -158,7 +158,7 @@ jobs:
});
} else {
// Create a new check run
await octokit.rest.checks.create({
await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Vercel Deployment Preview',
Expand All @@ -171,4 +171,3 @@ jobs:
},
});
}

0 comments on commit 7d62b07

Please sign in to comment.