Merge pull request #138 from weaponsforge/fix/weaponsforge-137 #50
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: Deploy to Firebase Hosting | |
# This workflow deploys the static-generated nextjs app to Firebase Hosting | |
# Triggered by push to the "dev" branch | |
on: | |
push: | |
branches: | |
- dev | |
jobs: | |
lint-export-client: | |
name: Lint and Export client | |
runs-on: ubuntu-latest | |
env: | |
NEXT_PUBLIC_BASE_PATH: '' | |
NEXT_PUBLIC_BASE_API_URL: ${{ secrets.NEXT_PUBLIC_BASE_API_URL_DEV }} | |
NEXT_PUBLIC_FIREBASE_WEB_API_KEY: ${{ secrets.FIREBASE_WEB_API_KEY_DEV }} | |
NEXT_PUBLIC_FIREBASE_WEB_AUTHDOMAIN: ${{ secrets.FIREBASE_WEB_AUTHDOMAIN_DEV }} | |
NEXT_PUBLIC_FIREBASE_WEB_PROJECT_ID: ${{ secrets.FIREBASE_WEB_PROJECT_ID_DEV }} | |
NEXT_PUBLIC_FIREBASE_WEB_STORAGE_BUCKET: ${{ secrets.FIREBASE_WEB_STORAGE_BUCKET_DEV }} | |
NEXT_PUBLIC_FIREBASE_WEB_MESSAGING_SENDER_ID: ${{ secrets.FIREBASE_WEB_MESSAGING_SENDER_ID_DEV }} | |
NEXT_PUBLIC_FIREBASE_WEB_APP_ID: ${{ secrets.FIREBASE_WEB_APP_ID_DEV }} | |
NEXT_PUBLIC_FIREBASE_WEB_MEASUREMENT_ID: ${{ secrets.FIREBASE_WEB_MEASUREMENT_ID_DEV }} | |
NEXT_PUBLIC_MEDIA_BG1: ${{ secrets.NEXT_PUBLIC_MEDIA_BG1 }} | |
NEXT_PUBLIC_RANDOM_JOKE_API: ${{ secrets.NEXT_PUBLIC_RANDOM_JOKE_API }} | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Use NodeJS v18.14.2 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.14.2 | |
- name: Install Dependencies | |
run: | | |
cd client | |
npm install | |
- name: Lint | |
run: | | |
cd client | |
npm run lint | |
- name: Export static files | |
run: | | |
cd client | |
npm run export | |
mv out/404/index.html out/404.html | |
- name: Archive Development Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dev-out | |
path: | | |
client/out | |
client/.firebaserc | |
client/firebase.json | |
retention-days: 3 | |
lint-server: | |
name: Lint Server | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Use NodeJS v18.14.2 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.14.2 | |
- name: Install Dependencies and lint | |
run: | | |
cd server | |
npm install | |
npm run lint | |
deploy-client: | |
name: Deploy Client to Firebase Hosting | |
needs: lint-export-client | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: dev-out | |
- name: Deploy to Firebase | |
uses: w9jds/firebase-action@master | |
with: | |
args: deploy --only hosting:dev | |
env: | |
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} | |
deploy-server: | |
name: Deploy Server to Vercel | |
needs: lint-server | |
runs-on: ubuntu-latest | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID_DEV }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_DEV }} | |
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Use NodeJS v18.14.2 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.14.2 | |
- name: Install Vercel CLI | |
run: npm install --global [email protected] | |
- name: Pull Vercel Environment Information | |
run: | | |
cd server | |
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Build Project Artifacts | |
run: | | |
cd server | |
npm install | |
npm run docs:vercel | |
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Deploy Project Artifacts to Vercel | |
run: | | |
cd server | |
vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Post Deployment Clean-up | |
run: | | |
cd server | |
rm -r -f .vercel |