diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..7b8b2e6 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,69 @@ +name: cd + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Gradle Caching + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Make application-prod.yml + run: | + cd ./src/main/resources + touch ./application-prod.yml + echo "${{ secrets.APPLICATION_PROD }}" > ./application-prod.yml + shell: bash + + - name: Grant Execute Permission For Gradlew + run: chmod +x gradlew + + - name: Build With Gradle + run: ./gradlew build + + - name: Docker build & push to docker repo + env: + DOCKER_PATH : .deploy/Dockerfile + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -f $DOCKER_PATH -t ${{ secrets.DOCKER_REPO }}/mookive . + docker push ${{ secrets.DOCKER_REPO }}/mookive + + - name: Deploy to Prob + uses: appleboy/ssh-action@master + id: deploy-prob + env: + DOCKER_COMPOSE : ".deploy/docker-compose.yml" + with: + host: ${{ secrets.EC2_HOST }} + username: ubuntu + key: ${{ secrets.EC2_KEY }} + envs: GITHUB_SHA + script: | + touch ./docker-compose.yml + echo "${{ secrets.DOCKER_COMPOSE }}" > ./docker-compose.yml + docker stop mookive + docker rm mookive + docker pull ${{ secrets.DOCKER_REPO }}/mookive + docker-compose up -d + docker image prune diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1dd5898 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: ci + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/Setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Gradle Caching + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Grant Execute Permission For Gradlew + run: chmod +x gradlew + + - name: Build With Gradle + run: ./gradlew build \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4396d18..22b5530 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: include: - - prod \ No newline at end of file + - prod