Skip to content

Commit c0848b4

Browse files
authored
Deploy showcase to firebase (#58)
Create workflows to build showcase and dynamic-form lib. Create workflow to link showcase preview link to the PR Create workflow to build and deploy showcase to firebase
1 parent 0b6671c commit c0848b4

8 files changed

Lines changed: 24928 additions & 12491 deletions

File tree

.firebaserc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"projects": {
3-
"default": "anecdotes-mfe-poc"
3+
"default": "dynamic-form-showcase"
44
},
55
"targets": {
6-
"anecdotes-mfe-poc": {
6+
"dynamic-form-showcase": {
77
"hosting": {
8-
"develop": [
9-
"anecdotes-mfe-poc"
8+
"previews": [
9+
"dynamic-form-showcase"
1010
]
1111
}
1212
}
1313
}
14-
}
14+
}

.github/workflows/base-build.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Base workflow for build.
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
branch:
7+
required: true
8+
type: string
9+
appName:
10+
required: true
11+
type: string
12+
artifactName:
13+
type: string
14+
default: ''
15+
16+
jobs:
17+
install-deps:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
name: Checkout Base
23+
24+
- name: Cache or restore node_modules
25+
id: cache-nodemodules
26+
uses: actions/cache@v2
27+
env:
28+
cache-name: cache-node-modules
29+
with:
30+
# caching node_modules
31+
path: node_modules
32+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
33+
restore-keys: |
34+
${{ runner.os }}-build-${{ env.cache-name }}-
35+
${{ runner.os }}-build-
36+
${{ runner.os }}-
37+
38+
- name: Install dependencies
39+
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
40+
run: npm ci --legacy-peer-deps
41+
42+
validate:
43+
needs: [install-deps]
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- uses: actions/checkout@v2
48+
name: Checkout Base
49+
50+
- name: Use Node.js
51+
uses: actions/setup-node@v3
52+
with:
53+
node-version: 14.18.0
54+
55+
- name: Cache or restore node_modules
56+
id: cache-nodemodules
57+
uses: actions/cache@v2
58+
env:
59+
cache-name: cache-node-modules
60+
with:
61+
# caching node_modules
62+
path: node_modules
63+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
64+
restore-keys: |
65+
${{ runner.os }}-build-${{ env.cache-name }}-
66+
${{ runner.os }}-build-
67+
${{ runner.os }}-
68+
69+
- name: Lint
70+
run: npx nx lint ${{ inputs.appName }} --quiet
71+
72+
- name: Test
73+
run: npx nx test ${{ inputs.appName }} --configuration=single-run
74+
75+
build:
76+
needs: [install-deps]
77+
runs-on: ubuntu-latest
78+
79+
steps:
80+
- uses: actions/checkout@v2
81+
name: Checkout Base
82+
83+
- name: Use Node.js
84+
uses: actions/setup-node@v3
85+
with:
86+
node-version: 14.18.0
87+
88+
- name: Cache or restore node_modules
89+
id: cache-nodemodules
90+
uses: actions/cache@v2
91+
env:
92+
cache-name: cache-node-modules
93+
with:
94+
# caching node_modules
95+
path: node_modules
96+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
97+
restore-keys: |
98+
${{ runner.os }}-build-${{ env.cache-name }}-
99+
${{ runner.os }}-build-
100+
${{ runner.os }}-
101+
102+
- name: Build
103+
run: npx nx build ${{ inputs.appName }}
104+
105+
- name: Upload app artifacts
106+
if: ${{ inputs.artifactName }}
107+
uses: actions/upload-artifact@master
108+
with:
109+
name: ${{ inputs.artifactName }}
110+
path: dist

.github/workflows/build-dynamic-form-develop.yml renamed to .github/workflows/build.yml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
name: Build/Test
2-
3-
on:
4-
push:
5-
branches: [master, develop]
6-
7-
jobs:
8-
build:
9-
runs-on: ubuntu-latest
10-
11-
steps:
12-
- uses: actions/checkout@v2
13-
14-
- name: Use Node.js
15-
uses: actions/setup-node@v1
16-
with:
17-
node-version: 14.15.4
18-
19-
- name: Install dependencies
20-
run: npm ci
21-
22-
- name: Build
23-
run: npm run build
24-
25-
- name: Lint
26-
run: npm run lint
27-
28-
- name: Test
29-
run: npm run test-single-run
1+
name: Build/Test
2+
3+
on:
4+
push:
5+
branches: [master, develop]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Use Node.js
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: 14.15.4
18+
19+
- name: Install dependencies
20+
run: npm ci
21+
22+
- name: Build
23+
run: npm run build
24+
25+
- name: Lint
26+
run: npm run lint
27+
28+
- name: Test
29+
run: npm run test-single-run

.github/workflows/dynamic-form-pr.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/pr.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build PR
2+
3+
on:
4+
pull_request:
5+
branches: [develop, master, 'feature/*']
6+
7+
concurrency:
8+
group: pr-build-${{ github.head_ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
build_lib:
13+
uses: ./.github/workflows/base-build.yml
14+
with:
15+
appName: dynamic-form
16+
branch: temp
17+
18+
build_showcase:
19+
uses: ./.github/workflows/base-build.yml
20+
with:
21+
appName: showcase
22+
branch: temp
23+
artifactName: showcase
24+
25+
create_showcase_preview_link:
26+
needs: [build_showcase]
27+
runs-on: ubuntu-latest
28+
env:
29+
FIREBASE_SERVICE_ACCOUNT: ${{ secrets.firebase_service_account }}
30+
31+
steps:
32+
- uses: actions/checkout@v2
33+
name: Checkout Base
34+
35+
- name: Use Node.js
36+
uses: actions/setup-node@v3
37+
with:
38+
node-version: 14.18.0
39+
40+
- name: Cache or restore node_modules
41+
id: cache-nodemodules
42+
uses: actions/cache@v2
43+
env:
44+
cache-name: cache-node-modules
45+
with:
46+
# caching node_modules
47+
path: node_modules
48+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
49+
restore-keys: |
50+
${{ runner.os }}-build-${{ env.cache-name }}-
51+
${{ runner.os }}-build-
52+
${{ runner.os }}-
53+
54+
- name: Download app artifacts
55+
uses: actions/download-artifact@master
56+
continue-on-error: true
57+
with:
58+
name: showcase
59+
path: dist
60+
61+
- name: Deploy to firebase
62+
uses: FirebaseExtended/action-hosting-deploy@v0
63+
with:
64+
repoToken: '${{ secrets.GITHUB_TOKEN }}'
65+
firebaseServiceAccount: '${{ env.FIREBASE_SERVICE_ACCOUNT }}'
66+
projectId: dynamic-form-showcase
67+
expires: 2d
68+
target: previews
69+
70+
check_for_failures:
71+
if: ${{ always() }}
72+
runs-on: ubuntu-latest
73+
name: Finish build
74+
needs: [build_lib,create_showcase_preview_link]
75+
steps:
76+
- name: Check build status
77+
if: ${{ needs.build_lib.result != 'success' || needs.create_showcase_preview_link.result != 'success' }}
78+
run: exit 1

firebase.json

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
{
2-
"hosting": [
2+
"hosting": [{
3+
"public": "dist/apps/showcase",
4+
"target": "previews",
5+
"ignore": [
6+
"firebase.json",
7+
"**/.*",
8+
"**/node_modules/**"
9+
],
10+
"rewrites": [
311
{
4-
"public": "dist",
5-
"target": "develop",
6-
"ignore": [
7-
"firebase.json",
8-
"**/.*",
9-
"**/node_modules/**"
10-
],
11-
"rewrites": [
12-
{
13-
"source": "**",
14-
"destination": "/apps/shell/index.html"
15-
}
16-
]
17-
}
18-
]
12+
"source": "**",
13+
"destination": "/index.html"
14+
}
15+
]
16+
}]
1917
}

0 commit comments

Comments
 (0)