-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (65 loc) · 2.74 KB
/
pull-request.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Runs when PR is created, updated, or reopened
name: Deploy to Firebase Hosting on PR
on: pull_request
jobs:
build_and_preview:
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '21.6.1'
- name: Check node.js version
run: node -v
- name: Install pnpm
run: npm install -g [email protected]
- name: Check pnpm version
run: pnpm -v
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Enable Firebase experiments
run: pnpm exec firebase experiments:enable webframeworks
- name: Firebase Deploy Preview
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_HIMANSHUJAIN_DEV }}'
projectId: himanshujain-dev
env:
FIREBASE_CLI_EXPERIMENTS: webframeworks
- name: Send status message
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COMMENT="Congratulations! The build was successful."
curl -sSL -H "Authorization: token $GITHUB_TOKEN" -d "{\"body\": \"$COMMENT\"}" -H "Content-Type: application/json" -X POST "https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${{ github.event.pull_request.number }}/comments"
- name: Send failure message with error details
if: failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COMMENT="Oops! The build failed."
curl -sSL -H "Authorization: token $GITHUB_TOKEN" -d "{\"body\": \"$COMMENT\"}" -H "Content-Type: application/json" -X POST "https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${{ github.event.pull_request.number }}/comments"
- name: Send Notification
if: success() # success(), failure()
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
# user credentials
username: ${{ secrets.EMAIL_USERNAME }}
password: ${{ secrets.EMAIL_PASSWORD }}
# email subject
subject: ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }}
# email body as text
body: ${{ github.job }} job in worflow ${{ github.workflow }} of ${{ github.repository }} has ${{ job.status }}
# comma-separated string, send email to
# from email name
from: GitHub Actions