Skip to content

[Env] .gitignore application.properties 추가 #21

[Env] .gitignore application.properties 추가

[Env] .gitignore application.properties 추가 #21

Workflow file for this run

name: Java CI with Gradle
on:
push:
branches: [ "main" ]
jobs:
CI:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
# .gitignore에 있는 properties파일 추가
- name: Add prod_properties
run: |
mkdir ./src/main/resources
touch ./src/main/resources/application.properties
echo "${{ secrets.PROPERTIES }}" > ./src/main/resources/application.properties
# .gitingnore에 있는 .env파일 docker compose 실행을 위해 추가
- name: Add .env
run: echo "${{ secrets.ENV }}" > .env
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle Wrapper
run: ./gradlew clean build --exclude-task test
# Docker Image Build and Push
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Build
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}
CD:
needs: [ CI ]
runs-on: ubuntu-latest
steps:
- name: Deploy .env to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEPLOYMENT_HOST }}
username: ${{ secrets.DEPLOYMENT_USERNAME }}
password: ${{ secrets.DEPLOYMENT_PASSWORD }}
key: ${{ secrets.SSH_KEY }}
source: .env
target: /home/serverking/marketplace
- name: Deploy docker compose file
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEPLOYMENT_HOST }}
username: ${{ secrets.DEPLOYMENT_USERNAME }}
password: ${{ secrets.DEPLOYMENT_PASSWORD }}
key: ${{ secrets.SSH_KEY }}
source: docker-compose.yml
target: /home/serverking/marketplace
- name: Deploy remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEPLOYMENT_HOST }}
username: ${{ secrets.DEPLOYMENT_USERNAME }}
password: ${{ secrets.DEPLOYMENT_PASSWORD }}
key: ${{ secrets.SSH_KEY }}
script_stop: true
script: |
cd marketplace
docker-compose pull
docker-compose up -d