add docker #1
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 | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
pull_request: {} | |
permissions: | |
actions: write | |
contents: read | |
jobs: | |
# lint: | |
# name: ⬣ ESLint | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: 🛑 Cancel Previous Runs | |
# uses: styfle/[email protected] | |
# - name: ⬇️ Checkout repo | |
# uses: actions/checkout@v3 | |
# # - name: Setup Bun | |
# # uses: oven-sh/setup-bun@v1 | |
# # - name: Install dependencies | |
# # run: npm install | |
# - name: ⎔ Setup node | |
# uses: actions/setup-node@v3 | |
# with: | |
# node-version: 20 | |
# - name: 📥 Download deps | |
# uses: bahmutov/npm-install@v1 | |
# - name: Install dependencies | |
# run: npm install | |
# - name: 🔬 Lint | |
# run: npm run lint | |
typecheck: | |
name: ʦ TypeScript | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🛑 Cancel Previous Runs | |
uses: styfle/[email protected] | |
- name: ⬇️ Checkout repo | |
uses: actions/checkout@v3 | |
# - name: Setup Bun | |
# uses: oven-sh/setup-bun@v1 | |
# - name: Install dependencies | |
# run: bun install | |
- name: ⎔ Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: 📥 Download deps | |
uses: bahmutov/npm-install@v1 | |
- name: 🔎 Type check | |
run: npm run typecheck | |
build: | |
name: 🐳 build | |
uses: ./.github/workflows/build.yml | |
secrets: inherit | |
deploy: | |
name: 🚀 Deploy | |
runs-on: [self-hosted] | |
needs: [typecheck, build] | |
# only build/deploy main branch on pushes | |
if: ${{ (github.ref == 'refs/heads/main') && github.event_name == 'push' }} | |
env: | |
JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
STRAPI_TOKEN: ${{ secrets.STRAPI_TOKEN }} | |
STRAPI_URL: ${{ secrets.STRAPI_URL }} | |
steps: | |
- name: 🛑 Cancel Previous Runs | |
uses: styfle/[email protected] | |
- name: ⬇️ Checkout repo | |
uses: actions/checkout@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: 🚀 Run Docker Compose on Production | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
docker pull algomax/ecommerce-frontend:production | |
docker compose -f docker-compose.prod.yaml up -d | |
docker system prune --all --volumes --force |