update workflow #11
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
to: [email protected] | |
# from email name | |
from: GitHub Actions |