Fix : env 권한 추가 #228
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to OCI Compute Instance | |
| on: | |
| push: | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Create FCM key file | |
| run: | | |
| mkdir -p src/main/resources | |
| echo '${{ secrets.FCM_SERVICE_ACCOUNT }}' > src/main/resources/tinybite_fcm.json | |
| - name: Build JAR | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew clean bootJar -x test | |
| cp $(ls build/libs/*.jar | grep -v plain | head -n 1) app.jar | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GHCR_TOKEN }} | |
| - name: Build & Push Docker image | |
| run: | | |
| IMAGE=${{ env.REGISTRY }}/${GITHUB_REPOSITORY,,}:latest | |
| docker build -t $IMAGE . | |
| docker push $IMAGE | |
| - name: Create .env file | |
| run: printf "%s" "${{ secrets.ENV_FILE }}" > .env | |
| - name: Copy files to OCI Instance | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.ORACLE_SSH_HOST }} | |
| username: ${{ secrets.ORACLE_SSH_USERNAME }} # OCI 기본값: ubuntu | |
| key: ${{ secrets.ORACLE_SSH_KEY }} | |
| port: 22 | |
| source: ".env,docker-compose.common.yml,nginx/" | |
| target: "/home/ubuntu/tinybite/" | |
| - name: Deploy on OCI Instance | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.ORACLE_SSH_HOST }} | |
| username: ${{ secrets.ORACLE_SSH_USERNAME }} | |
| key: ${{ secrets.ORACLE_SSH_KEY }} | |
| port: 22 | |
| debug: true | |
| script: | | |
| set -e | |
| cd /home/ubuntu/tinybite | |
| chmod 644 .env | |
| echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io \ | |
| -u ${{ github.actor }} --password-stdin | |
| echo "📦 이미지 pull 중..." | |
| docker-compose -f docker-compose.common.yml pull | |
| echo "🚀 컨테이너 재시작..." | |
| docker-compose -f docker-compose.common.yml up -d | |
| echo "🧹 정리 중..." | |
| docker image prune -f | |
| echo "✅ 배포 완료" |