ISC - Update Compatibility #1101
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: preview | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: [ready_for_review] | |
permissions: | |
pull-requests: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.issue.number || github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
preview: | |
if: | | |
github.event_name == 'workflow_dispatch' || | |
( | |
github.actor != 'dependabot[bot]' && | |
( | |
github.event.pull_request || | |
( | |
github.event.issue.pull_request && | |
contains(github.event.comment.body, '/create-preview') | |
) | |
) | |
) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.issue.pull_request && format('refs/pull/{0}/merge', github.event.issue.number) || '' }} | |
- name: Prepare Yarn | |
uses: ./.github/actions/prepare/ | |
- name: Prepare build | |
run: yarn prepare | |
shell: bash | |
- name: Generate API | |
run: yarn generate:api | |
shell: bash | |
- name: Build | |
run: yarn build | |
# Convert to Vercel project and upload | |
- name: Install Vercel CLI | |
run: npm install --global vercel@latest | |
- name: Pull Vercel Environment Information | |
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Build Project Artifacts | |
run: vercel build --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Deploy Project Artifacts to Vercel | |
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > vercel_output.txt | |
# Set the deploy URL as an output | |
- name: Set deploy url | |
id: deploy_url | |
run: echo "DEPLOY_URL=$(cat vercel_output.txt | awk 'END{print}')" >> $GITHUB_OUTPUT | |
- name: Print deploy url | |
run: echo ${{ steps.deploy_url.outputs.DEPLOY_URL }} | |
# Create a comment on the pull request with the deployed URL | |
- name: Comment on pull request | |
if: github.event_name != 'workflow_dispatch' | |
uses: actions/[email protected] | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const DEPLOY_URL = '${{ steps.deploy_url.outputs.DEPLOY_URL }}' | |
const COMMIT_SHA = '${{ github.event.pull_request.head.sha }}' | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `This pull request has been deployed to Vercel.\n\n\nLatest commit: ${COMMIT_SHA}\n\n:white_check_mark: Preview: ${DEPLOY_URL}` | |
}) |