From c13486d8d8da5c2915d79eafe47c582410d1471f Mon Sep 17 00:00:00 2001 From: KarmaPol Date: Fri, 5 Jul 2024 23:35:39 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20cicd=20=EA=B0=9C=ED=8E=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-prod-new.yml | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/deploy-prod-new.yml diff --git a/.github/workflows/deploy-prod-new.yml b/.github/workflows/deploy-prod-new.yml new file mode 100644 index 0000000..14aff90 --- /dev/null +++ b/.github/workflows/deploy-prod-new.yml @@ -0,0 +1,59 @@ +name: EC2 Deploy + +on: + push: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Create necessary directories + run: | + mkdir -p infra/infra-redis/src/main/resources + mkdir -p infra/infra-security/src/main/resources + mkdir -p infra/infra-s3/src/main/resources + mkdir -p data/src/main/resources + + - name: Create application-properties.yml + run: | + echo "${{ secrets.APPLICATION_REDIS }}" > infra/infra-redis/src/main/resources/application-redis.yml + echo "${{ secrets.APPLICATION_SECURITY }}" > infra/infra-security/src/main/resources/application-security.yml + echo "${{ secrets.APPLICATION_S3 }}" > infra/infra-s3/src/main/resources/application-s3.yml + echo "${{ secrets.APPLICATION_RDB }}" > data/src/main/resources/application-rdb.yml + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + + - name: Build with Gradle + run: ./gradlew build + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build the Docker image + run: docker build -t ${{ secrets.DOCKERHUB_REPOSITORY }}/kiwing-server:latest . + + - name: Docker Push + run: docker push ${{ secrets.DOCKERHUB_REPOSITORY }}/kiwing-server:latest + + - name: Trigger Portainer Webhook + run: | + PORTAINER_WEBHOOK_URL=${{ secrets.PORTAINER_WEBHOOK_DNS }} + curl -X POST -d "{}" -H "Content-Type: application/json" --insecure $PORTAINER_WEBHOOK_URL