-
Notifications
You must be signed in to change notification settings - Fork 3
167 lines (144 loc) · 4.51 KB
/
main.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: CI/CD
on:
push:
branches:
- 'master'
- 'next'
pull_request:
branches:
- "**"
env:
NODE_VERSION: '18.17'
PROJECT: designlab
# ^ Is important to note that the above is used as:
# * SENTRY project to deploy so naming must match
# * Repo badges creation and SENTRY
MAIN_BRANCH: 'master'
STAGING_BRANCH: 'next'
permissions:
packages: write
contents: read
id-token: write
jobs:
test:
name: Run Tests 🔬
runs-on: ubuntu-latest
steps:
- name: Checkout 📥
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- run: |
yarn install
yarn test --clearCache
- name: Running tests
run: yarn test --passWithNoTests --watchAll=false
select-deployment-target:
runs-on: ubuntu-latest
outputs:
target: ${{ steps.get-target.outputs.target }}
steps:
- name: Checkout 📥
uses: actions/checkout@v3
with:
fetch-depth: 0
- id: get-target
run: |
TARGET=review
if [[ ${{ github.event_name }} == "push" ]]; then
# TODO: The conditions here depend on the different deployment targets you have
if [[ ${{ github.ref }} == "refs/heads/master" ]]; then
TARGET=prod
elif [[ ${{ github.ref }} == "refs/heads/next" ]]; then
TARGET=next
fi
else
if [ ! -f .github/workflows/teardown.yml ]; then
echo "Set up the teardown flow and try again!"
exit 1
fi
fi
echo "target=$TARGET" >> $GITHUB_OUTPUT
deploy-app:
needs:
- select-deployment-target
- test
uses: Orfium/orfium-github-actions/.github/workflows/deploy-frontend.yml@master
concurrency: ${{ github.ref }}
with:
target-environment: ${{ needs.select-deployment-target.outputs.target }}
secrets:
ORG_PGP_TOKEN: ${{ secrets.ORG_PGP_TOKEN }}
deploy-docs:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
name: Deploy Docs
runs-on: ubuntu-latest
needs: deploy-app
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: yarn install
- name: Generate docs
run: yarn documentation:generate
- name: Clone docs repo
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: Orfium/docs
path: docs-repo
ssh-key: ${{ secrets.DOCS_DEPLOY_KEY }}
- name: Copy and commit docs
run: |
rm -rf $GITHUB_WORKSPACE/docs-repo/${GITHUB_REPOSITORY#*/}
mkdir -p $GITHUB_WORKSPACE/docs-repo/${GITHUB_REPOSITORY#*/}
cp -r typeDocs/* $GITHUB_WORKSPACE/docs-repo/${GITHUB_REPOSITORY#*/}/
cd $GITHUB_WORKSPACE/docs-repo/
git config --global user.email "[email protected]"
git config --global user.name "orfium-org"
git add .
git commit -m "Update ${GITHUB_REPOSITORY#*/} docs"
git push origin master
release:
needs:
- deploy-app
runs-on: ubuntu-latest
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next') && github.event_name == 'push'
permissions:
packages: write
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Get yarn cache 📦
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install
- name: Release 📌
if: "github.event_name == 'push'"
env:
GITHUB_NPM_CONFIG_REGISTRY: 'https://npm.pkg.github.com/'
GITHUB_NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLIC_NPM_CONFIG_REGISTRY: 'https://registry.npmjs.org'
PUBLIC_NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release