Skip to content

todo-next_v2.1.1

todo-next_v2.1.1 #16

Workflow file for this run

name: Deploy to Production Environment
# This workflow deploys the backend, a full-server express app to Vercel
# as opposed to their recommended approach of deploying serverless functions
# using NextJS "pages/api". Vercel CLI v28.2.0 is used for deployment
# 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 }}
BASE_API_URL: ${{ secrets.BASE_API_URL }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Use NodeJS v16.14.2
uses: actions/setup-node@v3
with:
node-version: 16.14.2
- name: Install Dependencies and lint
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: Disable Jekyll
run: |
cd client
touch out/.nojekyll
- name: Archive Development Artifact
uses: actions/upload-artifact@v3
with:
name: main-out
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 v16.14.2
uses: actions/setup-node@v3
with:
node-version: 16.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@v3
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 }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Use NodeJS v16.14.2
uses: actions/setup-node@v3
with:
node-version: 16.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
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