-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (42 loc) · 1.36 KB
/
firebase-preview.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
name: Firebase Preview Deploy
# Trigger the workflow on PRs to the main branch only
on:
pull_request:
branches:
- main
jobs:
deploy-preview:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install dependencies
run: npm install
- name: Build the app
run: npm run build
- name: Install Firebase CLI
run: npm install -g firebase-tools
- name: Deploy to Firebase Preview Channel
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
run: firebase hosting:channel:deploy pr-${{ github.event.number }} --expires 3d
# Step to post the preview link to the PR discussion
- name: Post preview link to PR
uses: actions/github-script@v7
with:
script: |
const previewUrl = `https://pr-${{ github.event.number }}--studybuddy-8086e.web.app`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🚀 Preview for this PR is available at: ${previewUrl}`
});