fix : 공백 제거 로직 추가 #174
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: CI | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| permissions: | |
| contents: read | |
| env: | |
| REGISTRY: ${{ secrets.OCIR_HOST }} | |
| 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) | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew clean bootJar | |
| JAR=$(ls build/libs/*.jar | head -n 1) | |
| cp "$JAR" app.jar | |
| - name: Compute image name (OCIR) | |
| id: img | |
| run: | | |
| REG="$(printf '%s' "${{ secrets.OCIR_HOST }}" | tr -d '\r\n')" | |
| NS="$(printf '%s' "${{ secrets.OCIR_TENANCY_NAMESPACE }}" | tr -d '\r\n')" | |
| REPO="$(printf '%s' "${{ secrets.OCIR_REPO }}" | tr -d '\r\n')" | |
| echo "name=${REG}/${NS}/${REPO}" >> "$GITHUB_OUTPUT" | |
| - name: Log in to OCIR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ secrets.OCIR_HOST }} | |
| username: ${{ secrets.OCIR_USERNAME }} | |
| password: ${{ secrets.OCIR_AUTH_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=sha | |
| - name: Set up Docker Build | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Create .env file | |
| run: echo "${{ secrets.ENV_FILE }}" > .env | |
| - name: Copy files to OCI Compute | |
| 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/" | |
| - name: Deploy to OCI Compute | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_KEY }} | |
| port: 22 | |
| script: | | |
| set -e | |
| cd /home/ubuntu/tinybite | |
| mv /home/ubuntu/tinybite/docker/* /home/ubuntu/tinybite/ || true | |
| echo "${{ secrets.OCIR_AUTH_TOKEN }}" | docker login "${{ secrets.OCIR_HOST }}" \ | |
| -u "${{ secrets.OCIR_USERNAME }}" --password-stdin | |
| export APP_IMAGE="${{ secrets.OCIR_HOST }}/${{ secrets.OCIR_TENANCY_NAMESPACE }}/${{ secrets.OCIR_REPO }}:latest" | |
| 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 |