Skip to content

feat: Optimizations #71

feat: Optimizations

feat: Optimizations #71

Workflow file for this run

name: Release
on:
push:
branches:
- main
env:
IMAGE_REPOSITORY: lennetech/deploy.party
jobs:
version:
name: Version
runs-on: ubuntu-latest
if: github.ref_name == 'dev' || github.ref_name == 'main'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install dependencies
run: npm install
- name: Create version
run: npm run release
- name: Save version
run: echo "VERSION=$(cat .version)" >> $GITHUB_ENV
- name: Upload version artifact
uses: actions/upload-artifact@v3
with:
name: version
path: .version
include-hidden-files: 'true'
build_frontend:
name: Build Frontend
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download version artifact
uses: actions/download-artifact@v3
with:
name: version
- name: Login to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Load Version
id: load_version
run: echo "VERSION=$(cat .version)" >> $GITHUB_ENV
- name: Build and push frontend image
env:
FRONTEND_IMAGE: ghcr.io/${{ env.IMAGE_REPOSITORY }}/app
run: |
docker pull $FRONTEND_IMAGE:latest || true
docker build -f Dockerfile-app \
--cache-from $FRONTEND_IMAGE:latest \
--tag $FRONTEND_IMAGE:$VERSION .
docker push $FRONTEND_IMAGE:$VERSION
build_backend:
name: Build Backend
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download version artifact
uses: actions/download-artifact@v3
with:
name: version
- name: Login to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Load Version
id: load_version
run: echo "VERSION=$(cat .version)" >> $GITHUB_ENV
- name: Build and push backend image
env:
BACKEND_IMAGE: ghcr.io/${{ env.IMAGE_REPOSITORY }}/api
run: |
docker pull $BACKEND_IMAGE:latest || true
docker build -f Dockerfile-api \
--cache-from $BACKEND_IMAGE:latest \
--tag $BACKEND_IMAGE:$VERSION .
docker push $BACKEND_IMAGE:$VERSION
push_frontend_latest:
name: Push Frontend Latest
runs-on: ubuntu-latest
if: github.ref_name == 'main'
needs: build_frontend
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download version artifact
uses: actions/download-artifact@v3
with:
name: version
- name: Login to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Load Version
id: load_version
run: echo "VERSION=$(cat .version)" >> $GITHUB_ENV
- name: Tag and push latest frontend image
env:
FRONTEND_IMAGE: ghcr.io/${{ env.IMAGE_REPOSITORY }}/app
run: |
docker pull $FRONTEND_IMAGE:$VERSION
docker tag $FRONTEND_IMAGE:$VERSION $FRONTEND_IMAGE:latest
docker push $FRONTEND_IMAGE:latest
push_backend_latest:
name: Push Backend Latest
runs-on: ubuntu-latest
if: github.ref_name == 'main'
needs: build_backend
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download version artifact
uses: actions/download-artifact@v3
with:
name: version
- name: Login to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Load Version
id: load_version
run: echo "VERSION=$(cat .version)" >> $GITHUB_ENV
- name: Tag and push latest backend image
env:
BACKEND_IMAGE: ghcr.io/${{ env.IMAGE_REPOSITORY }}/api
run: |
docker pull $BACKEND_IMAGE:$VERSION
docker tag $BACKEND_IMAGE:$VERSION $BACKEND_IMAGE:latest
docker push $BACKEND_IMAGE:latest
push_frontend_tag:
name: Push Frontend Tag
runs-on: ubuntu-latest
needs: build_frontend
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download version artifact
uses: actions/download-artifact@v3
with:
name: version
- name: Login to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Load Version
id: load_version
run: echo "VERSION=$(cat .version)" >> $GITHUB_ENV
- name: Tag and push branch frontend image
env:
FRONTEND_IMAGE: ghcr.io/${{ env.IMAGE_REPOSITORY }}/app
run: |
docker pull $FRONTEND_IMAGE:$VERSION
docker tag $FRONTEND_IMAGE:$VERSION $FRONTEND_IMAGE:${{ github.ref_name }}
docker push $FRONTEND_IMAGE:${{ github.ref_name }}
push_backend_tag:
name: Push Backend Tag
runs-on: ubuntu-latest
needs: build_backend
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download version artifact
uses: actions/download-artifact@v3
with:
name: version
- name: Login to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Load Version
id: load_version
run: echo "VERSION=$(cat .version)" >> $GITHUB_ENV
- name: Tag and push branch backend image
env:
BACKEND_IMAGE: ghcr.io/${{ env.IMAGE_REPOSITORY }}/api
run: |
docker pull $BACKEND_IMAGE:$VERSION
docker tag $BACKEND_IMAGE:$VERSION $BACKEND_IMAGE:${{ github.ref_name }}
docker push $BACKEND_IMAGE:${{ github.ref_name }}