feat: use playwright test suit #154
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: Vercel Preview Deployment | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
Deploy-Preview: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Pull Vercel Environment Information | |
run: yarn dlx vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Build Project Artifacts | |
run: yarn dlx vercel build --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Deploy Project Artifacts to Vercel | |
id: deploy | |
run: | | |
yarn dlx vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > deploy.log | |
URL=$(cat deploy.log | grep -o 'https://[^ ]*.vercel.app' | head -n1) | |
echo "deploymentUrl=$URL" >> $GITHUB_OUTPUT | |
- name: Comment URL to PR | |
uses: actions/github-script@v6 | |
id: comment-deployment-url-script | |
env: | |
DEPLOYMENT_URL: ${{ steps.deploy.outputs.deploymentUrl }} | |
with: | |
script: | | |
// Get pull requests that are open for current ref. | |
const pullRequests = await github.rest.pulls.list({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'open', | |
head: `${context.repo.owner}:${context.ref.replace('refs/heads/', '')}` | |
}) | |
// Set issue number for following calls from context (if on pull request event) or from above variable. | |
const issueNumber = context.issue.number || pullRequests.data[0].number | |
// Retrieve existing bot comments for the PR | |
const {data: comments} = await github.rest.issues.listComments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber, | |
}) | |
const botComment = comments.find(comment => { | |
return comment.user.type === 'Bot' && comment.body.includes('Deployed at') | |
}) | |
const output = "Deployed at " + process.env.DEPLOYMENT_URL | |
// If we have a comment, update it, otherwise create a new one | |
if (botComment) { | |
github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: botComment.id, | |
body: output | |
}) | |
} else { | |
github.rest.issues.createComment({ | |
issue_number: issueNumber, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: output | |
}) | |
} |