Merge pull request #128 from EnigmaVSSUT/eventFunction #39
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
name: Build and Deploy to Firebase Hosting | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
Build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '19' | |
- name: Install Dependencies | |
run: npm install --force | |
- name: Set Environment Variables | |
run: | | |
echo "VITE_BASE_API=${{ secrets.VITE_BASE_API }}" >> $GITHUB_ENV | |
echo "VITE_CDN_URL=${{ secrets.VITE_CDN_URL }}" >> $GITHUB_ENV | |
echo "VITE_DOMAIN_NAME=${{ secrets.VITE_DOMAIN_NAME }}" >> $GITHUB_ENV | |
echo "VITE_GITHUB_APP_AUTHORIZE_URL=${{ secrets.VITE_GITHUB_APP_AUTHORIZE_URL }}" >> $GITHUB_ENV | |
- name: Build Vite Project | |
run: npm run build | |
- name: Archive Build | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build | |
path: dist/ | |
Deploy-Staging: | |
needs: [Build] | |
runs-on: ubuntu-latest | |
environment: | |
name: Preview | |
url: "https://enigma-web-preview.web.app" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '19' | |
- name: Install Firebase CLI | |
run: npm install -g firebase-tools | |
- name: Install Dependencies | |
run: npm install --force | |
- name: Restore Build | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
- name: Set Environment Variables Staging | |
run: echo "FIREBASE_PROJECT_ID=${{ secrets.PREVIEW }}" >> $GITHUB_ENV | |
- name: Deploy to Firebase (Staging) | |
run: firebase deploy --token ${{ secrets.FIREBASE_TOKEN }} --only hosting --project ${{ env.FIREBASE_PROJECT_ID }} | |
Deploy-Production: | |
needs: [Build,Deploy-Staging] | |
runs-on: ubuntu-latest | |
environment: | |
name: Production | |
url: "https://enigma-dev-web.web.app" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '19' | |
- name: Install Firebase CLI | |
run: npm install -g firebase-tools | |
- name: Install Dependencies | |
run: npm install --force | |
- name: Restore Build | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
- name: Set Environment Variables for Production | |
run: echo "FIREBASE_PROJECT_ID=${{ secrets.PRODUCTION }}" >> $GITHUB_ENV | |
- name: Deploy to Firebase (Production) | |
run: firebase deploy --token ${{ secrets.FIREBASE_TOKEN }} --only hosting --project ${{ env.FIREBASE_PROJECT_ID }} |