Skip to content

Merge pull request #78 from SSASINSA/refactor/sprint-fix(#68) #48

Merge pull request #78 from SSASINSA/refactor/sprint-fix(#68)

Merge pull request #78 from SSASINSA/refactor/sprint-fix(#68) #48

Workflow file for this run

name: 프론트 빌드 및 배포 (GHCR + Compose)
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
packages: write
env:
IMAGE_NAME: ghcr.io/ssasinsa/wearagain-admin-frontend
concurrency:
group: deploy-admin-frontend
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Write .env.production
run: |
umask 077
printf '%s' "${{ secrets.ENV }}" > .env.production
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build & Push admin-frontend (with cache)
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ github.sha }}
labels: |
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=${{ github.repository }}
cache-from: |
type=gha
type=registry,ref=${{ env.IMAGE_NAME }}:latest
cache-to: type=gha,mode=max
provenance: false
sbom: false
- name: Cleanup
run: rm -f .env.production
deploy:
runs-on: self-hosted
needs: build
steps:
- name: Login to GHCR (runner)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Ensure deploy dir
run: mkdir -p /opt/wearagain
- name: Ensure nginx up (safety)
working-directory: /opt/wearagain
run: docker compose up -d nginx
- name: Pull latest admin-frontend image
working-directory: /opt/wearagain
run: docker compose pull admin-frontend || true
- name: Restart only admin-frontend
working-directory: /opt/wearagain
run: |
docker compose up -d --no-deps --pull always admin-frontend
docker image prune -f