-
Notifications
You must be signed in to change notification settings - Fork 16
61 lines (59 loc) · 2.18 KB
/
build-publish.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
name: Build & Publish
on:
push:
branches: "**"
pull_request:
types: [closed]
branches: [development, master]
paths-ignore:
- "**/*"
env:
HUSKY: "0"
jobs:
set-environment:
runs-on: ubuntu-latest
outputs:
deploy_env: ${{ steps.bootstrap-env.outputs.deploy_env }}
grf_version: ${{ steps.bootstrap-env.outputs.grf_version }}
target_branch: ${{ steps.bootstrap-env.outputs.target_branch }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Bootstrap Environment
id: bootstrap-env
run: |
TARGET_BRANCH=${{ github.event.pull_request.base.ref || github.ref_name }}
echo "::set-output name=target_branch::$TARGET_BRANCH"
echo "TARGET_BRANCH=$TARGET_BRANCH" >> $GITHUB_ENV
GRF_VERSION=$(node -p "require('./package.json').version")
echo "::set-output name=grf_version::$GRF_VERSION"
echo "GRF_VERSION=$GRF_VERSION" >> $GITHUB_ENV
if [[ "$TARGET_BRANCH" == "main" ]]; then
echo "::set-output name=deploy_env::Production"
echo "DEPLOY_ENV=Production" >> $GITHUB_ENV
else
echo "::set-output name=deploy_env::Preview"
echo "DEPLOY_ENV=Dev" >> $GITHUB_ENV
fi
- name: Inspect Environment
run: |
echo "GRF_VERSION: $GRF_VERSION"
echo "TARGET_BRANCH: $TARGET_BRANCH"
build:
runs-on: ubuntu-latest
if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.merged) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build
run: |
npm install
npm run build