chore: migrate to yarn #268
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 workflow | |
# The event triggers are configured as following: | |
# - on any pull request, trigger the workflow | |
# This is to avoid running the workflow twice on pull requests. | |
on: | |
pull_request: | |
jobs: | |
deploy-preview: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Read .nvmrc | |
run: echo ::set-output name=NVMRC::$(cat .nvmrc) | |
id: nvm | |
- name: Setup Node (uses version in .nvmrc) | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "${{ steps.nvm.outputs.NVMRC }}" | |
- name: Get yarn cache | |
id: yarn-cache | |
run: echo "::set-output name=dir::$(yarn config get cacheFolder)" | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ steps.yarn-cache.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Building application | |
run: yarn build | |
- name: Extract branch name | |
id: branch | |
# Extract the branch name and replace `/` or `.` with `-`. | |
# ${parameter//pattern/string} | |
# Notice the double `//` to replace all occurrences. | |
run: | | |
echo "Extracting branch name ${{ github.head_ref }}" | |
branch_name=${{ github.head_ref }} | |
echo "::set-output name=name::$(echo ${branch_name//[\/|\.]/-})" | |
shell: bash | |
- name: Deploying to surge (preview) | |
run: yarn deploy | |
env: | |
APPLICATION_ID: ${{ secrets.APPLICATION_ID_STAGING }} | |
APPLICATION_URL: https://graphql-explorer-commercetools-${{ steps.branch.outputs.name }}.surge.sh | |
HOST_GCP_STAGING: ${{ secrets.HOST_GCP_STAGING }} | |
CTP_INITIAL_PROJECT_KEY: ${{ secrets.CYPRESS_PROJECT_KEY }} | |
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }} | |
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} |