Update README.md #4
Workflow file for this run
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
name: Deploy Preview | |
on: | |
pull_request: | |
branches: | |
- main | |
- develop | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.17.0' | |
- name: Install dependencies | |
run: npm install | |
- name: Build application | |
run: npm run build | |
- 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: | | |
DEPLOY_URL=$(npx vercel --prod --token $VERCEL_TOKEN --confirm | tail -n 1) | |
echo "Vercel Deployment URL: $DEPLOY_URL" | |
echo "DEPLOY_URL=$DEPLOY_URL" >> $GITHUB_ENV | |
id: vercel-deploy | |
- name: Comment on Pull Request | |
uses: actions/github-script@v6 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
script: | | |
const { DEPLOY_URL } = process.env; | |
const issue_number = context.payload.pull_request.number; | |
await github.rest.issues.createComment({ | |
issue_number: issue_number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Deployed to Vercel: ${DEPLOY_URL}` | |
}); |