Skip to content

Commit

Permalink
Update deploy-zeit-staging.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Demmonius authored Sep 21, 2020
1 parent 357ae45 commit 636dc0b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/deploy-zeit-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
branches-ignore:
- 'master'
workflow_dispatch: # Allow manual trigger via a button in github or a HTTP call: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#manually-running-a-workflow
inputs:
client:
description: 'Client to deploy'
required: false


jobs:
Expand Down Expand Up @@ -45,10 +49,15 @@ jobs:
run: |
# Print the version of the "now" CLI being used (helps debugging)
now --version
# Selecting client to deploy
MANUAL_TRIGGER_CLIENT="${{ github.event.inputs.client}}"
CLIENT_TO_DEPLOY="${MANUAL_TRIGGER_CLIENT:-$(cat now.json | jq -r '.build.env.NEXT_PUBLIC_CUSTOMER_REF')}"
# Deploy the customer on Vercel using the customer specified in now.json (e.g: "yarn deploy:customer1")
# Store the output in a variable so we can extract metadata from it
ZEIT_DEPLOYMENT_OUTPUT=`yarn deploy:$(cat now.json | jq -r '.build.env.NEXT_PUBLIC_CUSTOMER_REF') --token $ZEIT_TOKEN`
ZEIT_DEPLOYMENT_OUTPUT=`yarn deploy:$CLIENT_TO_DEPLOY --token $ZEIT_TOKEN`
# Extract the Vercel deployment url from the deployment output
ZEIT_DEPLOYMENT_URL=`echo $ZEIT_DEPLOYMENT_OUTPUT | egrep -o 'https?://[^ ]+.vercel.app'`
Expand All @@ -61,7 +70,7 @@ jobs:
if [[ ${CURRENT_BRANCH##*/} =~ ^v[0-9]{1,}- ]]; then # Checking if pattern matches with "vX-" where X is a number
ZEIT_DEPLOYMENT_ALIAS=${CURRENT_BRANCH##*/}
else
ZEIT_DEPLOYMENT_ALIAS=$(cat now.json | jq -r '.name')-${CURRENT_BRANCH##*/}
ZEIT_DEPLOYMENT_ALIAS=$(cat now.$CLIENT_TO_DEPLOY.staging.json | jq -r '.name')-${CURRENT_BRANCH##*/}
fi
# Zeit alias only allows 41 characters in the domain name, so we only keep the first 41 (41 = 53 - 11 - 1) characters (because Zeit needs 7 chars for ".vercel.app" at the end of the domain name, and count starts at 1, not 0)
Expand Down

0 comments on commit 636dc0b

Please sign in to comment.