Skip to content

빌드 및 배포 (Admin / GHCR + Compose) #3

빌드 및 배포 (Admin / GHCR + Compose)

빌드 및 배포 (Admin / GHCR + Compose) #3

Workflow file for this run

name: 빌드 및 배포 (Admin / GHCR + Compose)
on:
push:
branches: ["develop"]
workflow_dispatch:
permissions:
contents: read
packages: write
env:
IMAGE_NAME: ghcr.io/ssasinsa/wearagain-admin-backend
concurrency:
group: deploy-admin-develop
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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 to GHCR
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ github.sha }}
labels: |
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=${{ github.repository }}
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 & .env
run: |
mkdir -p /opt/wearagain
if [ ! -f /opt/wearagain/.env ]; then
umask 077
printf '%s' "${{ secrets.ENV }}" > /opt/wearagain/.env
fi
- name: Deploy admin service only (ensure nginx)
working-directory: /opt/wearagain
run: |
docker compose up -d nginx
docker compose pull admin
docker compose up -d --no-deps admin
docker image prune -f