my-phonebook_v2.1.1 #15
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
name: Deploy to Production Environment | |
# This workflow will trigger on any tag/release created on *any* branch | |
# Make sure to create tags/releases only from the "master" branch for consistency | |
on: | |
release: | |
types: [published] | |
jobs: | |
lint-client: | |
name: Lint and Export client | |
if: github.event.release.target_commitish == 'master' | |
runs-on: ubuntu-latest | |
env: | |
NEXT_PUBLIC_BASE_PATH: ${{ secrets.NEXT_PUBLIC_BASE_PATH }} | |
NEXT_PUBLIC_BASE_API_URL: ${{ secrets.NEXT_PUBLIC_BASE_API_URL_PROD }} | |
BASE_API_URL: ${{ secrets.BASE_API_URL }} | |
NEXT_PUBLIC_FIREBASE_WEB_API_KEY: ${{ secrets.FIREBASE_WEB_API_KEY_PROD }} | |
NEXT_PUBLIC_FIREBASE_WEB_AUTHDOMAIN: ${{ secrets.FIREBASE_WEB_AUTHDOMAIN_PROD }} | |
NEXT_PUBLIC_FIREBASE_WEB_PROJECT_ID: ${{ secrets.FIREBASE_WEB_PROJECT_ID_PROD }} | |
NEXT_PUBLIC_FIREBASE_WEB_STORAGE_BUCKET: ${{ secrets.FIREBASE_WEB_STORAGE_BUCKET_PROD }} | |
NEXT_PUBLIC_FIREBASE_WEB_MESSAGING_SENDER_ID: ${{ secrets.FIREBASE_WEB_MESSAGING_SENDER_ID_PROD }} | |
NEXT_PUBLIC_FIREBASE_WEB_APP_ID: ${{ secrets.FIREBASE_WEB_APP_ID_PROD }} | |
NEXT_PUBLIC_FIREBASE_WEB_MEASUREMENT_ID: ${{ secrets.FIREBASE_WEB_MEASUREMENT_ID_PROD }} | |
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 Client | |
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: Disable Jekyll | |
run: | | |
cd client | |
touch out/.nojekyll | |
- name: Archive Development Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: main-out | |
include-hidden-files: true | |
path: client/out | |
retention-days: 3 | |
lint-server: | |
name: Lint Server | |
if: github.event.release.target_commitish == 'master' | |
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 Github Pages | |
if: github.event.release.target_commitish == 'master' | |
needs: lint-client | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: main-out | |
- name: List files for publish | |
run: ls -l -a | |
- name: Deploy to Github Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./ | |
publish_branch: gh-pages | |
deploy-server: | |
name: Deploy Server to Vercel | |
if: github.event.release.target_commitish == 'master' | |
needs: lint-server | |
runs-on: ubuntu-latest | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID_PROD }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_PROD }} | |
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 | |
docker-build-push: | |
name: Push Image to Docker Hub | |
if: github.event.release.target_commitish == 'master' && vars.DOCKERHUB_USERNAME != '' | |
needs: | |
- lint-client | |
- lint-server | |
runs-on: ubuntu-latest | |
steps: | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.release.tag_name }} | |
- name: Create env variables | |
run: | | |
cp client/.env.example client/.env | |
cp server/.env.example server/.env | |
- name: Build Image | |
run: docker compose -f docker-compose.dev.yml build | |
- name: Push Image to Docker Hub | |
run: docker compose -f docker-compose.dev.yml push |