-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (51 loc) · 1.96 KB
/
deploy-preview.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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 }}