Skip to content

feat: stop hiding featured project #270

feat: stop hiding featured project

feat: stop hiding featured project #270

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
jobs:
detect-changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
steps:
- name: Checkout
uses: actions/checkout@v3
# For pull requests it's not necessary to checkout the code
- name: Check Paths
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend:
- 'apps/api/**'
- 'pnpm-lock.yaml'
frontend:
- 'apps/client/**'
- 'pnpm-lock.yaml'
build-push-frontend:
name: Build and Push Frontend Container
runs-on: ubuntu-latest
needs: detect-changes
if: ${{ needs.detect-changes.outputs.frontend == 'true' }}
environment:
name: prod
env:
PRIVATE_OUTLINE_SERVER: ${{ secrets.PRIVATE_OUTLINE_SERVER }}
PRIVATE_OUTLINE_API_TOKEN: ${{ secrets.PRIVATE_OUTLINE_API_TOKEN }}
PUBLIC_API_URL: ${{ secrets.PUBLIC_API_URL }}
PUBLIC_URL: ${{ secrets.PUBLIC_URL }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Setup Dependencies
uses: ./.github/composite-actions/setup
- name: Build Frontend
run: echo $PUBLIC_URL && echo $PUBLIC_API_URL && pnpm nx codegen:prod client && pnpm nx build client
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: registry.ham-san.net
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and Push frontend image
uses: docker/build-push-action@v5
with:
file: ./apps/client/Dockerfile
context: .
push: true
tags: registry.ham-san.net/ham-san-net-client:latest
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
build-push-backend:
name: Build and Push Backend Container
runs-on: ubuntu-latest
environment:
name: prod
needs: detect-changes
if: ${{ needs.detect-changes.outputs.backend == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Setup Dependencies
uses: ./.github/composite-actions/setup
- name: Build Backend
run: pnpm nx build api
- name: Login to Registry (Again just in case)
uses: docker/login-action@v3
with:
registry: registry.ham-san.net
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push backend image
uses: docker/build-push-action@v5
with:
file: ./apps/api/Dockerfile
context: ./dist/apps/api
push: true
tags: registry.ham-san.net/ham-san-net-api:latest
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
Deploy:
name: Deploy to VM
needs:
- build-push-frontend
- build-push-backend
- detect-changes
runs-on: ubuntu-latest
if: ${{ needs.detect-changes.outputs.backend == 'true' || needs.detect-changes.outputs.frontend == 'true' }}
environment:
name: prod
url: https://ham-san.net
steps:
- name: Deploy to VM via SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
eval "$(ssh-agent -s)"
ssh-add - <<< "${{ secrets.GH_PRIVATE_KEY }}"
cd ./ham-san-net
git pull origin main
./pre-deploy.sh
- name: Deploy Backend
uses: appleboy/ssh-action@master
if: ${{ needs.detect-changes.outputs.backend == 'true' }}
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
cd ./ham-san-net
./deploy-backend.sh
- name: Deploy Frontend
uses: appleboy/ssh-action@master
if: ${{ needs.detect-changes.outputs.frontend == 'true' }}
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
cd ./ham-san-net
./deploy-frontend.sh
- name: Running Page Speed Insights
uses: jakepartusch/[email protected]
id: psi
with:
url: ${{ secrets.PUBLIC_URL }}
threshold: 70
strategy: mobile
key: ${{ secrets.PSI_API_KEY }}