11---
22
3- name : test, build and deploy
3+ name : Test & Build
44on :
55 release :
66 types :
1212 - ' **'
1313
1414jobs :
15- test :
15+
16+ Setup :
1617 runs-on : ubuntu-latest
17- strategy :
18- matrix :
19- node-version : [13.x]
18+ outputs :
19+ ENVIRONMENT : ${{ env.ENVIRONMENT }}
2020 steps :
21- - name : Checkout Repo
22- uses : actions/checkout@v2
23- - run : yarn install
24- - run : yarn test
25- build :
26- runs-on : ubuntu-latest
27- strategy :
28- matrix :
29- node-version : [13.x]
30- steps :
31- - name : Checkout Repo
32- uses : actions/checkout@v2
33-
3421 - name : Set env to DEV
3522 if : github.repository_owner != 'ProteGO-Safe'
3623 && startsWith(github.ref, 'refs/heads/release/')
3724 && github.event_name == 'push'
3825 run : |
3926 echo "ENVIRONMENT=DEV" >> $GITHUB_ENV
40-
27+
4128 - name : Set env to STAGE
4229 if : startsWith(github.ref, 'refs/tags/')
4330 && github.repository_owner != 'ProteGO-Safe'
4431 && ( github.event.release.target_commitish == 'master' || startsWith( github.event.release.target_commitish, 'release' ))
4532 && github.event_name == 'release'
4633 run : |
4734 echo "ENVIRONMENT=STAGE" >> $GITHUB_ENV
48-
35+
4936 - name : Set env to PROD
5037 if : startsWith(github.ref, 'refs/tags/')
5138 && github.repository_owner == 'ProteGO-Safe'
@@ -54,12 +41,58 @@ jobs:
5441 run : |
5542 echo "ENVIRONMENT=PROD" >> $GITHUB_ENV
5643
44+ Test :
45+ runs-on : ubuntu-latest
46+ strategy :
47+ matrix :
48+ node-version : [13.x]
49+ steps :
50+ - name : Checkout Repo
51+ uses : actions/checkout@v2
52+ - name : Get yarn cache directory path
53+ id : yarn-cache-dir-path
54+ run : echo "::set-output name=dir::$(yarn cache dir)"
55+ - uses : actions/cache@v2
56+ id : yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
57+ with :
58+ path : ${{ steps.yarn-cache-dir-path.outputs.dir }}
59+ key : ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
60+ restore-keys : |
61+ ${{ runner.os }}-yarn-
62+ - run : yarn install
63+ - run : yarn test
64+
65+ Build :
66+ runs-on : ubuntu-latest
67+ needs : [Setup]
68+ strategy :
69+ matrix :
70+ node-version : [13.x]
71+ env :
72+ ENVIRONMENT : ${{ needs.Setup.outputs.ENVIRONMENT }}
73+
74+ steps :
75+ - name : Checkout Repo
76+ uses : actions/checkout@v2
77+
78+ - name : Get yarn cache directory path
79+ id : yarn-cache-dir-path
80+ run : echo "::set-output name=dir::$(yarn cache dir)"
81+
82+ - uses : actions/cache@v2
83+ id : yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
84+ with :
85+ path : ${{ steps.yarn-cache-dir-path.outputs.dir }}
86+ key : ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
87+ restore-keys : |
88+ ${{ runner.os }}-yarn-
89+
5790 - name : Set Env's
5891 run : echo "PROJECT_ENVS=${{ secrets[env.EV] }}" >> $GITHUB_ENV
5992 env :
6093 EV : " ${{ env.ENVIRONMENT }}_ENV"
61- if : env.ENVIRONMENT == 'STAGE' || env.ENVIRONMENT == 'PROD' || env. ENVIRONMENT == 'DEV'
62-
94+ if : ${{ needs.Setup.outputs. ENVIRONMENT }}
95+
6396 - name : Upload PL locale to the POEditor
6497 run : |
6598 sh locales/scripts/upload.sh -l pl -i $POEDITOR_ID -t $POEDITOR_TOKEN | grep '"code":"200"' || exit 1
@@ -72,17 +105,17 @@ jobs:
72105 run : echo "CURL_COMMAND=${{ secrets[env.CURL] }}" >> $GITHUB_ENV
73106 env :
74107 CURL : " ${{ env.ENVIRONMENT }}_CURL"
75- if : env.ENVIRONMENT == 'STAGE' || env.ENVIRONMENT == 'PROD' || env. ENVIRONMENT == 'DEV'
108+ if : ${{ needs.Setup.outputs. ENVIRONMENT }}
76109
77110 - name : Inject ENV's for builds
78111 run : ' echo "$PROJECT_ENVS" |base64 --decode > .env'
79112 shell : bash
80- if : env.ENVIRONMENT == 'STAGE' || env.ENVIRONMENT == 'PROD' || env. ENVIRONMENT == 'DEV'
113+ if : ${{ needs.Setup.outputs. ENVIRONMENT }}
81114
82115 - name : Exec correct curl
83116 run : ' base64 -d <<< $CURL_COMMAND | sh || true'
84117 shell : bash
85- if : env.ENVIRONMENT == 'STAGE' || env.ENVIRONMENT == 'PROD' || env. ENVIRONMENT == 'DEV'
118+ if : ${{ needs.Setup.outputs. ENVIRONMENT }}
86119
87120 - name : Show GITHUB_CONTEXT
88121 run : |
@@ -96,85 +129,8 @@ jobs:
96129 - run : yarn build
97130
98131 - name : Archive Artifact
99- if : ( env.ENVIRONMENT == 'STAGE' || env.ENVIRONMENT == 'PROD' || env .ENVIRONMENT == 'DEV' )
132+ if : ${{ needs.Setup.outputs .ENVIRONMENT }}
100133 uses : actions/upload-artifact@master
101134 with :
102135 name : build
103136 path : build
104- deploy :
105- needs : build
106- runs-on : ubuntu-latest
107- if : ( startsWith(github.ref, 'refs/tags') && github.event_name == 'release' ) || ( startsWith(github.ref, 'refs/heads/release/') && github.event_name == 'push' && github.repository_owner != 'ProteGO-Safe' )
108- steps :
109- - name : Checkout Repo
110- uses : actions/checkout@v2
111-
112- - name : Set env to DEV
113- if : github.repository_owner != 'ProteGO-Safe'
114- && startsWith(github.ref, 'refs/heads/release/')
115- && github.event_name == 'push'
116- run : |
117- echo "name=ENVIRONMENT=DEV" >> $GITHUB_ENV
118-
119- - name : Set env to STAGE
120- if : startsWith(github.ref, 'refs/tags/')
121- && github.repository_owner != 'ProteGO-Safe'
122- && startsWith( github.event.release.target_commitish, 'release' )
123- && github.event_name == 'release'
124- run : |
125- echo "ENVIRONMENT=STAGE" >> $GITHUB_ENV
126-
127- - name : Set env to PROD
128- if : startsWith(github.ref, 'refs/tags/')
129- && github.repository_owner == 'ProteGO-Safe'
130- && ( github.event.release.target_commitish == 'master' || startsWith( github.event.release.target_commitish, 'release/3' ))
131- && github.event_name == 'release'
132- run : |
133- echo "ENVIRONMENT=PROD" >> $GITHUB_ENV
134-
135- - name : Download Artifact
136- uses : actions/download-artifact@master
137- with :
138- name : build
139- path : build
140-
141- - name : Set Env's from Git refs.
142- run : |
143- echo "SOURCE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
144- echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
145- echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
146- echo "GCP_SA_KEY=${{ secrets[env.SECRET_ENV] }}" >> $GITHUB_ENV
147- echo "SECRET_PROJECT=${{ secrets[env.PROJECT_ENV] }}" >> $GITHUB_ENV
148- echo "SITE_PROJECT=${{ secrets[env.SITE_ENV] }}" >> $GITHUB_ENV
149- env :
150- SECRET_ENV : " ${{ env.ENVIRONMENT }}_FIREBASE_HOSTING_SAFE"
151- PROJECT_ENV : " ${{ env.ENVIRONMENT }}_FIREBASE_PROJECT"
152- SITE_ENV : " ${{ env.ENVIRONMENT }}_FIREBASE_SITE"
153- if : env.ENVIRONMENT == 'STAGE' || env.ENVIRONMENT == 'PROD' || env.ENVIRONMENT == 'DEV'
154-
155- - name : Set SITE_PROJECT for V4 PROD
156- run : |
157- echo "SITE_PROJECT=${{ secrets[env.SITE_ENV] }}-v4" >> $GITHUB_ENV
158- env :
159- SITE_ENV : " ${{ env.ENVIRONMENT }}_FIREBASE_SITE"
160- if : ( env.ENVIRONMENT == 'PROD' && github.event.release.target_commitish == 'master' )
161-
162- - name : Set SITE_PROJECT for V3 in PROD
163- run : |
164- echo "SITE_PROJECT=${{ secrets[env.SITE_ENV] }}" >> $GITHUB_ENV
165- env :
166- SITE_ENV : " ${{ env.ENVIRONMENT }}_FIREBASE_SITE"
167- if : ( env.ENVIRONMENT == 'PROD' && startsWith( github.event.release.target_commitish, 'release/3' ) )
168-
169- - run : cp firebase.json build/
170- if : ( env.ENVIRONMENT == 'STAGE' || env.ENVIRONMENT == 'PROD' || env.ENVIRONMENT == 'DEV' )
171-
172- - name : Sed Firebase.json
173- run : sed -ie 's|site_to_sed|${{ env.SITE_PROJECT }}|g' firebase.json
174- if : ( env.ENVIRONMENT == 'STAGE' || env.ENVIRONMENT == 'PROD' || env.ENVIRONMENT == 'DEV' )
175-
176- - name : Deploy to Firebase
177- if : ( env.ENVIRONMENT == 'STAGE' || env.ENVIRONMENT == 'PROD' || env.ENVIRONMENT == 'DEV' )
178- uses : w9jds/firebase-action@master
179- with :
180- args : deploy --only hosting --project $SECRET_PROJECT
0 commit comments