File tree Expand file tree Collapse file tree 5 files changed +102
-18
lines changed Expand file tree Collapse file tree 5 files changed +102
-18
lines changed Original file line number Diff line number Diff line change 1
- # This file was auto-generated by the Firebase CLI
2
- # https://github.com/firebase/firebase-tools
3
-
4
1
name : Deploy to Firebase Hosting on merge
5
2
' on ' :
6
3
push :
7
4
branches :
8
5
- main
9
6
env :
10
- VITE_CONTENTFUL_SPACE_ID : ${{secrets.VITE_CONTENTFUL_SPACE_ID }}
11
- VITE_CONTENTFUL_CONTENT_DELIVERY_ACCESS_TOKEN : ${{secrets.VITE_CONTENTFUL_CONTENT_DELIVERY_ACCESS_TOKEN }}
12
- VITE_CONTENTFUL_CONTENT_PREVIEW_ACCESS_TOKEN : ${{secrets.VITE_CONTENTFUL_CONTENT_PREVIEW_ACCESS_TOKEN }}
7
+ VITE_CONTENTFUL_SPACE_ID : ${{secrets.VITE_CONTENTFUL_STAGING_SPACE_ID }}
8
+ VITE_CONTENTFUL_CONTENT_DELIVERY_ACCESS_TOKEN : ${{secrets.VITE_CONTENTFUL_STAGING_CONTENT_DELIVERY_ACCESS_TOKEN }}
9
+ VITE_CONTENTFUL_CONTENT_PREVIEW_ACCESS_TOKEN : ${{secrets.VITE_CONTENTFUL_STAGING_CONTENT_PREVIEW_ACCESS_TOKEN }}
13
10
VITE_CONTENTFUL_ENVIRONMENT : ${{secrets.VITE_CONTENTFUL_ENVIRONMENT}}
14
- VITE_CONTENTFUL_GTAG_ID : ${{secrets.VITE_CONTENTFUL_GTAG_ID }}
11
+ VITE_CONTENTFUL_GTAG_ID : ${{secrets.VITE_CONTENTFUL_STAGING_GTAG_ID }}
15
12
jobs :
16
13
build_and_deploy :
17
14
runs-on : ubuntu-latest
24
21
firebaseServiceAccount : ' ${{ secrets.FIREBASE_SERVICE_ACCOUNT_SAVITSKY_MUSEUM }}'
25
22
channelId : live
26
23
projectId : savitsky-museum
24
+ target : staging-savitsky-museum
Original file line number Diff line number Diff line change 1
- # This file was auto-generated by the Firebase CLI
2
- # https://github.com/firebase/firebase-tools
3
-
4
1
name : Deploy to Firebase Hosting on PR
5
2
' on ' : pull_request
3
+ permissions :
4
+ checks : write
5
+ contents : read
6
+ pull-requests : write
6
7
env :
7
- VITE_CONTENTFUL_SPACE_ID : ${{secrets.VITE_CONTENTFUL_SPACE_ID }}
8
- VITE_CONTENTFUL_CONTENT_DELIVERY_ACCESS_TOKEN : ${{secrets.VITE_CONTENTFUL_CONTENT_DELIVERY_ACCESS_TOKEN }}
9
- VITE_CONTENTFUL_CONTENT_PREVIEW_ACCESS_TOKEN : ${{secrets.VITE_CONTENTFUL_CONTENT_PREVIEW_ACCESS_TOKEN }}
8
+ VITE_CONTENTFUL_SPACE_ID : ${{secrets.VITE_CONTENTFUL_STAGING_SPACE_ID }}
9
+ VITE_CONTENTFUL_CONTENT_DELIVERY_ACCESS_TOKEN : ${{secrets.VITE_CONTENTFUL_STAGING_CONTENT_DELIVERY_ACCESS_TOKEN }}
10
+ VITE_CONTENTFUL_CONTENT_PREVIEW_ACCESS_TOKEN : ${{secrets.VITE_CONTENTFUL_STAGING_CONTENT_PREVIEW_ACCESS_TOKEN }}
10
11
VITE_CONTENTFUL_ENVIRONMENT : ${{secrets.VITE_CONTENTFUL_ENVIRONMENT}}
11
- VITE_CONTENTFUL_GTAG_ID : ${{secrets.VITE_CONTENTFUL_GTAG_ID }}
12
+ VITE_CONTENTFUL_GTAG_ID : ${{secrets.VITE_CONTENTFUL_STAGING_GTAG_ID }}
12
13
jobs :
13
14
build_and_preview :
14
15
if : ' ${{ github.event.pull_request.head.repo.full_name == github.repository }}'
15
16
runs-on : ubuntu-latest
16
17
steps :
17
18
- uses : actions/checkout@v4
18
- - run : npm ci && npm run build
19
+ - name : Set up Node.js
20
+ uses : actions/setup-node@v4
21
+ with :
22
+ node-version : ' 20'
23
+ - name : Install dependencies
24
+ run : npm ci
25
+ - name : Run Jest tests
26
+ run : npm run test
27
+ - name : Build
28
+ run : npm run build
19
29
- uses : FirebaseExtended/action-hosting-deploy@v0
20
30
with :
21
31
repoToken : ' ${{ secrets.GITHUB_TOKEN }}'
22
32
firebaseServiceAccount : ' ${{ secrets.FIREBASE_SERVICE_ACCOUNT_SAVITSKY_MUSEUM }}'
23
- projectId : savitsky-museum
33
+ projectId : savitsky-museum
Original file line number Diff line number Diff line change
1
+ name : Deploy to Firebase Hosting on release
2
+ ' on ' :
3
+ release :
4
+ types : [released]
5
+ env :
6
+ VITE_CONTENTFUL_SPACE_ID : ${{secrets.VITE_CONTENTFUL_SPACE_ID}}
7
+ VITE_CONTENTFUL_CONTENT_DELIVERY_ACCESS_TOKEN : ${{secrets.VITE_CONTENTFUL_CONTENT_DELIVERY_ACCESS_TOKEN}}
8
+ VITE_CONTENTFUL_CONTENT_PREVIEW_ACCESS_TOKEN : ${{secrets.VITE_CONTENTFUL_CONTENT_PREVIEW_ACCESS_TOKEN}}
9
+ VITE_CONTENTFUL_ENVIRONMENT : ${{secrets.VITE_CONTENTFUL_ENVIRONMENT}}
10
+ VITE_CONTENTFUL_GTAG_ID : ${{secrets.VITE_CONTENTFUL_GTAG_ID}}
11
+ jobs :
12
+ build_and_deploy :
13
+ runs-on : ubuntu-latest
14
+ steps :
15
+ - uses : actions/checkout@v4
16
+ - run : npm ci && npm run build
17
+ - uses : FirebaseExtended/action-hosting-deploy@v0
18
+ with :
19
+ repoToken : ' ${{ secrets.GITHUB_TOKEN }}'
20
+ firebaseServiceAccount : ' ${{ secrets.FIREBASE_SERVICE_ACCOUNT_SAVITSKY_MUSEUM }}'
21
+ channelId : live
22
+ projectId : savitsky-museum
23
+ target : savitsky-museum
Original file line number Diff line number Diff line change @@ -16,3 +16,41 @@ Instruction for setting up firebase hosting.
16
16
h) "What script should be run before every deploy" - choose default - "npm ci && npm run build"<br>
17
17
i) "Set up autpmatic deployment to your site's live channel when a PR is a merged" - y<br>
18
18
j) "What is the name of the GitHub branch associated with your site's live channel" - choose default - "main"<br>
19
+
20
+ For handling multiple environments:
21
+ 1 . Go to a Firebase Console (https://console.firebase.google.com/ ) -> Hosting -> Add another site ![ Screenshot 2024-07-23 131226] ( https://github.com/user-attachments/assets/b966efbe-a70f-4448-ab4e-1d76539bc0e7 )
22
+ 2 . Add a website id, e.g. "staging-website"
23
+ 3 . Update firebase json by adding a new site for "staging-website" and corrected main website. "site" should be equal to your site ID in firebase. e.g.
24
+ ``` json
25
+ {
26
+ "hosting" : [{
27
+ "site" : " production" ,
28
+ "public" : " public" ,
29
+ "ignore" : [
30
+ " firebase.json" ,
31
+ " **/.*" ,
32
+ " **/node_modules/**"
33
+ ],
34
+ "rewrites" : [
35
+ {
36
+ "source" : " **" ,
37
+ "destination" : " /index.html"
38
+ }
39
+ ]
40
+ }, {
41
+ "site" : " staging-website" ,
42
+ "public" : " public" ,
43
+ "ignore" : [
44
+ " firebase.json" ,
45
+ " **/.*" ,
46
+ " **/node_modules/**"
47
+ ],
48
+ "rewrites" : [
49
+ {
50
+ "source" : " **" ,
51
+ "destination" : " /index.html"
52
+ }
53
+ ]
54
+ }]
55
+ }
56
+ ```
Original file line number Diff line number Diff line change 1
1
{
2
- "hosting" : {
2
+ "hosting" : [{
3
+ "site" : " savitsky-museum" ,
3
4
"public" : " public" ,
4
5
"ignore" : [
5
6
" firebase.json" ,
12
13
"destination" : " /index.html"
13
14
}
14
15
]
15
- }
16
+ }, {
17
+ "site" : " staging-savitsky-museum" ,
18
+ "public" : " public" ,
19
+ "ignore" : [
20
+ " firebase.json" ,
21
+ " **/.*" ,
22
+ " **/node_modules/**"
23
+ ],
24
+ "rewrites" : [
25
+ {
26
+ "source" : " **" ,
27
+ "destination" : " /index.html"
28
+ }
29
+ ]
30
+ }]
16
31
}
You can’t perform that action at this time.
0 commit comments