1+ name : Deploy Admin App to Firebase
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ paths :
8+ - ' projects/admin/**'
9+ - ' firebase.json'
10+ - ' .firebaserc'
11+ - ' package*.json'
12+ pull_request :
13+ branches :
14+ - main
15+ paths :
16+ - ' projects/admin/**'
17+ - ' firebase.json'
18+ - ' .firebaserc'
19+ - ' package*.json'
20+
21+ jobs :
22+ build-and-deploy :
23+ runs-on : ubuntu-latest
24+
25+ steps :
26+ - name : Checkout code
27+ uses : actions/checkout@v4
28+
29+ - name : Setup Node.js
30+ uses : actions/setup-node@v4
31+ with :
32+ node-version : ' 20'
33+ cache : ' npm'
34+
35+ - name : Install dependencies
36+ run : npm ci
37+
38+ - name : Lint admin project
39+ run : npm run lint:admin
40+
41+ - name : Test admin project
42+ run : npm run test -- admin --watch=false --browsers=ChromeHeadless
43+
44+ - name : Build admin project
45+ run : ng build admin --configuration=production
46+
47+ - name : Deploy to Firebase Preview (PR)
48+ if : github.event_name == 'pull_request'
49+ uses : FirebaseExtended/action-hosting-deploy@v0
50+ with :
51+ repoToken : ' ${{ secrets.GITHUB_TOKEN }}'
52+ firebaseServiceAccount : ' ${{ secrets.FIREBASE_SERVICE_ACCOUNT_ANGULAR_ADMIN_BLOG }}'
53+ projectId : angular-admin-blog
54+ channelId : pr-${{ github.event.number }}
55+ target : admin
56+ expires : 7d
57+ env :
58+ FIREBASE_CLI_EXPERIMENTS : webframeworks
59+
60+ - name : Deploy to Firebase Live (Main Branch)
61+ if : github.ref == 'refs/heads/main' && github.event_name == 'push'
62+ uses : FirebaseExtended/action-hosting-deploy@v0
63+ with :
64+ repoToken : ' ${{ secrets.GITHUB_TOKEN }}'
65+ firebaseServiceAccount : ' ${{ secrets.FIREBASE_SERVICE_ACCOUNT_ANGULAR_ADMIN_BLOG }}'
66+ projectId : angular-admin-blog
67+ channelId : live
68+ target : admin
69+ env :
70+ FIREBASE_CLI_EXPERIMENTS : webframeworks
71+
72+ - name : Add PR Comment
73+ if : github.event_name == 'pull_request'
74+ uses : actions/github-script@v7
75+ with :
76+ script : |
77+ const { data: comments } = await github.rest.issues.listComments({
78+ owner: context.repo.owner,
79+ repo: context.repo.repo,
80+ issue_number: context.issue.number,
81+ });
82+
83+ const botComment = comments.find(comment =>
84+ comment.user.type === 'Bot' &&
85+ comment.body.includes('🔥 Firebase Admin Preview')
86+ );
87+
88+ const body = `
89+ ## 🔥 Firebase Admin Preview Deployed
90+
91+ **Preview URL**: https://angular-admin-blog--pr-${{ github.event.number }}-8t1hsdkv.web.app
92+
93+ Changes in this PR have been deployed to a preview channel.
94+ The preview will be available for 7 days.
95+
96+ ### What's included:
97+ - ✅ Admin application build
98+ - ✅ Security headers configured
99+ - ✅ SPA routing enabled
100+ - ✅ Production optimizations
101+ `;
102+
103+ if (botComment) {
104+ await github.rest.issues.updateComment({
105+ owner: context.repo.owner,
106+ repo: context.repo.repo,
107+ comment_id: botComment.id,
108+ body: body
109+ });
110+ } else {
111+ await github.rest.issues.createComment({
112+ owner: context.repo.owner,
113+ repo: context.repo.repo,
114+ issue_number: context.issue.number,
115+ body: body
116+ });
117+ }
0 commit comments