Skip to content

refactor

refactor #241

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
env:
PORT: 80
ENV: 'testing'
DOMAIN: 'https://close-powerlifting.jaw.dev'
PASSWORD_SALT: 5
COOKIE_EXPIRATION: 60000
JWT_SECRET: 'yeahhhhhhhhhhh'
SESSION_SECRET: 'something someting'
COOKIE_PASSWORD: 'cookie password'
COOKIE_NAME: 'what is this cookie name'
SESSION_NAME: 'something cool'
ADMIN_EMAIL: '[email protected]'
ADMIN_NAME: 'jaw'
API_URL: 'https://www.openpowerlifting.org/api'
BASE_URL: 'https://www.openpowerlifting.org/'
X_API_KEY: ''
EMAIL_HOST: 'mailhot' # docker
EMAIL_PORT: 1025 # docker
EMAIL_AUTH_EMAIL: ''
EMAIL_AUTH_PASS: ''
jobs:
format:
name: Prettier format
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [19.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm i
- name: Format codes
run: npm run format
lint:
name: ESLint
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [19.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm i
- name: Lint codes
run: npm run lint
test:
name: Unit tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [19.x]
services:
mongodb:
image: mongo:latest
ports:
- 27017:27017
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm i
- name: Test codes
run: npm run test
deploy:
needs: [format, test, lint]
name: Deploy to production
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
environment:
name: production
url: https://close-powerlifting.jaw.dev/
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_TOKEN }}
- name: Preset Image Name
run: echo "IMAGE_URL=$(echo ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:$(echo ${{ github.sha }} | cut -c1-7) | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and push Docker Image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.prod
push: true
tags: ${{ env.IMAGE_URL }}
- name: Deploy Image to Production
uses: caprover/[email protected]
with:
server: '${{ secrets.CAPROVER_SERVER }}'
app: '${{ secrets.APP_NAME }}'
token: '${{ secrets.APP_TOKEN }}'
image: ${{ env.IMAGE_URL }}