Merge pull request #274 from cardano-foundation/qa/dtis-419-generate-… #206
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
# Workflow to build and deploy site to Vercel using static files | |
# Name of Workflow | |
name: vercel-deploy-develop-branch (main vercel URL) | |
# Controls when the action will run. Triggers the workflow on push | |
# events but only for specified branches | |
on: | |
push: | |
branches: | |
- develop | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "deploy-production" | |
deploy-staging: | |
runs-on: self-hosted | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- name: Make some more metadata available as variables | |
id: metadata | |
run: | | |
if [ ${{github.event_name }} == "pull_request" ] | |
then | |
echo "::set-output name=DEPLOY_NAME::PR-$(echo $GITHUB_REF | awk -F/ '{ print $3 }')" | |
else | |
echo "::set-output name=DEPLOY_NAME::BRANCH-${GITHUB_REF##*/}" | |
fi | |
# Checks-out your repository under $GITHUB_WORKSPACE | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
submodules: recursive # Fetch private content | |
fetch-depth: 1 # Fetch all history for .GitInfo and .Lastmod | |
lfs: true | |
# Initiate GH deployment status | |
- name: Start Deployment | |
uses: bobheadxi/[email protected] | |
id: deployment | |
with: | |
step: start | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: vercel-deploy-${{ steps.metadata.outputs.DEPLOY_NAME }} | |
- name: Setup Node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18' | |
- name: Run unit tests | |
env: | |
NODE_OPTIONS: "--max_old_space_size=8192" | |
run: | | |
npm ci | |
npm run test | |
- name: 🔨 Build project | |
run: npm run build | |
- name: Configure vercel.json | |
run: | | |
cat > build/vercel.json <<EOF | |
{ | |
"rewrites": [ | |
{ | |
"source": "/((?!^/$).*)", | |
"destination": "/index.html" | |
} | |
] | |
} | |
EOF | |
# Push our generated site to Vercel | |
- name: Deploy to Vercel | |
uses: amondnet/vercel-action@v20 | |
id: vercel-action | |
with: | |
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required | |
#github-token: ${{ secrets.GITHUB_TOKEN }} #Optional | |
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} #Required | |
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} # Required | |
github-comment: false | |
vercel-args: '--prod' #Optional | |
working-directory: build | |
# Update GH deployment status | |
- name: Update Deployment Status | |
uses: bobheadxi/[email protected] | |
if: always() | |
with: | |
step: finish | |
token: ${{ secrets.GITHUB_TOKEN }} | |
status: ${{ job.status }} | |
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | |
env_url: ${{ steps.vercel-action.outputs.preview-url }} | |
- name: Comment PR | |
uses: thollander/actions-comment-pull-request@v1 | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
message: 'Vercel PR (merge commit) deploy URL: ${{ steps.vercel-action.outputs.preview-url }}' | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |