Skip to content

CD (Preview)

CD (Preview) #533

name: CD (Preview)
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
- cron: '0 12 * * *'
permissions: read-all
jobs:
dev_deploy:
name: Build and Deploy for Preview
if: ${{ github.repository == 'sws2apps/sws2apps-web' && github.ref == 'refs/heads/main' }}
environment:
name: Preview
url: https://preview-admin.sws2apps.com
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout for release preparation
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
ref: main
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: current
- name: Install package dependencies
run: npm ci
- name: Build the website
run: npm run build
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
VITE_FIREBASE_APIKEY: ${{ secrets.VITE_FIREBASE_APIKEY }}
VITE_FIREBASE_AUTHDOMAIN: ${{ secrets.VITE_FIREBASE_AUTHDOMAIN }}
VITE_FIREBASE_PROJECTID: ${{ secrets.VITE_FIREBASE_PROJECTID }}
VITE_BACKEND_API: ${{ secrets.VITE_BACKEND_API }}
- name: Check if new version has been generated
id: check_build
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6
with:
files: 'dist'
- name: Deploy to Firebase
if: ${{ steps.check_build.outputs.files_exists == 'true' }}
uses: sws2apps/firebase-deployment@354a91d7bdc88e4dcb2c84774f7438c5a9276dce
with:
workloadIdentityProvider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
serviceAccount: ${{ secrets.SERVICE_ACCOUNT }}
project: 'dev-sws2apps'