Skip to content

fix: script

fix: script #6

# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on push
'on':
push:
branches:
- main
jobs:
# Build job
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout SSG
uses: actions/checkout@v3
with:
repository: sensasi-delight/sensasi-dictionary-ssg
path: './_ssg'
# TODO: make this dynamic
- name: Generate .env
working-directory: ./_ssg
run: |
touch .env
echo "BASE_URL=https://kamus-webdev.web.app" >> .env
echo "NEXT_PUBLIC_BASE_URL=https://kamus-webdev.web.app" >> .env
- name: Replace script if any
run: |
if [ -f "${{ github.workspace }}/_ssg_asset/script.js" ]; then
cp -f "${{ github.workspace }}/_ssg_asset/script.js" "${{ github.workspace }}/_ssg/public/script.js"
fi
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/_ssg/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/_ssg/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"
cache: ${{ steps.detect-package-manager.outputs.manager }}
cache-dependency-path: './_ssg/package-lock.json'
- name: Restore cache
uses: actions/cache@v3
with:
path: |
_ssg/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Install dependencies
working-directory: ./_ssg
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Build with Next.js
working-directory: ./_ssg
run: ${{ steps.detect-package-manager.outputs.runner }} next build
- name: Static HTML export with Next.js
working-directory: ./_ssg
run: ${{ steps.detect-package-manager.outputs.runner }} next export
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: ./_ssg/out
- name: Deploy to Firebase Hosting
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_KAMUS_WEBDEV }}'
channelId: live
projectId: kamus-webdev