Skip to content

hotfix : party image 자료형 수정 (List<String> -> String) #38

hotfix : party image 자료형 수정 (List<String> -> String)

hotfix : party image 자료형 수정 (List<String> -> String) #38

Workflow file for this run

name: CI
on:
push:
branches: [ "main" ]
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
cache: gradle
- name: Build + Test(Gradle)
if: ${{ hashFiles('**/build.gradle*') != '' }}
run: |
chmod +x ./gradlew
./gradlew clean bootJar
JAR=$(ls build/libs/*.jar | head -n 1)
cp "$JAR" app.jar
- name: Compute image name (change to lowercase)
id: img
run: echo "name=${{ env.REGISTRY }}/${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Extract Docker metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.img.outputs.name }}
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=ref,event=tag
type=sha
- name: Set up Docker Build
uses: docker/setup-buildx-action@v3
- name: Debug paths
run: |
pwd
ls -la
find . -maxdepth 3 -iname 'Dockerfile' -print
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# .env 생성
- name: Create .env file
run: echo "${{ secrets.ENV_FILE }}" > .env
# EC2로 파일 전송
- name: Copy files to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: 22
source: "docker/*,.env,nginx/,deploy.sh"
target: "/home/ubuntu/tinybite/"
# EC2에서 도커 컨테이너 재배포
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: 22
script: |
cd /home/ubuntu/tinybite
mv /home/ubuntu/tinybite/docker/* /home/ubuntu/tinybite/
export GHCR_TOKEN=${{ secrets.GHCR_TOKEN }}
export GHCR_USERNAME=${{ github.actor }}
echo $GHCR_TOKEN | docker login ghcr.io -u $GHCR_USERNAME --password-stdin
docker compose -f docker-compose.blue.yml pull
docker compose -f docker-compose.blue.yml down || true
docker compose -f docker-compose.blue.yml up -d
docker image prune -a -f