Skip to content

chore : Update deploy.yml #17

chore : Update deploy.yml

chore : Update deploy.yml #17

Workflow file for this run

name: auto deploy with NCP Registry
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
RESOURCE_PATH: /home/runner/work/2024_BEOTKKOTTHON_TEAM_32_BE/2024_BEOTKKOTTHON_TEAM_32_BE/src/main/resources
permissions:
contents: read
checks: write
jobs:
push_to_registry_and_Deploy:
name: Push to NCP Container Registry
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Make gradlew executable
run: chmod +x ./gradlew
# Decrypt the encrypted application-secret.yml file
- name: Decrypt application-prod yml
run: gpg --quiet --batch --yes --always-trust --decrypt --passphrase=${{ secrets.APPLICATION_PROD_YML }} --output $RESOURCE_PATH/application.tar $RESOURCE_PATH/application.tar.gpg
shell: bash
# Unzip the application.tar file
- name: Unzip application.tar file to application-prod.yml
run: |
cd $RESOURCE_PATH
tar xvf application.tar
shell: bash
- name: Build with Gradle
run: ./gradlew build -x test
# Record test results as comments in PR
- name: Write test results in comments to Pull Request
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: '**/build/test-results/test/TEST-*.xml'
# If a test fails, write a check comment to the failed code line
- name: If a test fails, write a check comment to the failed code line
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
token: ${{ github.token }}
# - name: Prepare keystore
# run: echo "${{ secrets.KEYSTORE }}" > keystore.p12
# - name: Move keystore file to Docker build context
# run: mv keystore.p12 src/main/resources/
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# - name: Login to NCP Container Registry
# uses: docker/login-action@v2
# with:
# registry: ${{ secrets.NCP_CONTAINER_REGISTRY }}
# username: ${{ secrets.NCP_ACCESS_KEY }}
# password: ${{ secrets.NCP_SECRET_KEY }}
# - name: Build and Push Docker Image
# uses: docker/build-push-action@v3
# with:
# context: .
# file: ./Dockerfile
# push: true
# tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/balpyo-server:latest
# cache-from: type=registry,ref=${{ secrets.NCP_CONTAINER_REGISTRY }}/balpyo-server:latest
# cache-to: type=inline
# secrets: |
# GIT_AUTH_TOKEN=${{ secrets.GIT_TOKEN }}
# - name: Connect to Server and Pull from Container Registry
# uses: appleboy/[email protected]
# with:
# host: ${{ secrets.NCP_SERVER_IP }}
# username: ${{ secrets.NCP_SERVER_USERNAME }}
# password: ${{ secrets.NCP_SERVER_PASSWORD }}
# port: ${{ secrets.NCP_SERVER_PORT }}
# script: |
# echo "${{ secrets.NCP_SECRET_KEY }}" | docker login -u ${{ secrets.NCP_ACCESS_KEY }} --password-stdin ${{ secrets.NCP_CONTAINER_REGISTRY }}
# latest_tag=$(docker pull --quiet ${{ secrets.NCP_CONTAINER_REGISTRY }}/balpyo-server:latest | grep -oP "(?<=digest: ).*")
# echo "-----------------Latest tag found: ${{ secrets.LATEST_TAG }}"
# container_id=$(docker ps -aq)
# if [ ! -z "$container_id" ]; then
# docker stop $container_id
# docker rm $container_id
# fi
# docker run -d -p 443:443
# ${{ secrets.NCP_CONTAINER_REGISTRY }}/balpyo-server:${{ secrets.LATEST_TAG }}
# docker image prune -f