-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: #76 Comment on the pull request with the deployment URL
- Loading branch information
Showing
1 changed file
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,45 @@ | ||
name: Preview on Vercel | ||
|
||
on: | ||
# Run this workflow whenever a pull request is opened, synchronized, or reopened | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
branches: | ||
- main | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Check Out Code | ||
uses: actions/checkout@v2 | ||
|
||
# Deploy to Vercel | ||
- name: Deploy to Vercel | ||
env: | ||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | ||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | ||
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | ||
run: | | ||
npm install -g vercel | ||
vercel deploy --prod | ||
vercel deploy --target preview | ||
export DEPLOYMENT_URL=$(vercel --json list | jq -r '.[0].url') | ||
# Comment on the pull request with the deployment URL | ||
- name: Comment on Pull Request | ||
uses: actions/github-script@v5 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const context = github.context; | ||
const deploymentUrl = process.env.DEPLOYMENT_URL; | ||
const prNumber = context.payload.pull_request.number; | ||
const repo = context.repo.owner + "/" + context.repo.repo; | ||
github.issues.createComment({ | ||
repo: repo, | ||
issue_number: prNumber, | ||
body: `Preview deployment is ready at ${deploymentUrl}`, | ||
}); |