Merge pull request #115 from soma-baekgu/feature/BG-257-ongoing-event… #25
This file contains 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/CD DEVELOP' | |
on: | |
push: | |
branches: | |
- 'develop' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
- name: Cache Gradle packages | |
uses: actions/[email protected] | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: make application.yml | |
run: | | |
cd ./api/src/main/resources/ | |
touch ./application.yaml | |
echo "${{ secrets.YAML_DEV }}" > ./application.yaml | |
shell: bash | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
- name: Docker build & Push | |
run: | | |
docker login -u ${{ secrets.DOCKER_ID }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_ID }}/backgu:dev . | |
docker push ${{ secrets.DOCKER_ID }}/backgu:dev | |
- name: Deploy Images with Docker compose | |
uses: appleboy/[email protected] | |
env: | |
APP: "backgu-dev" | |
COMPOSE: "/home/ec2-user/compose/docker-compose-dev.yaml" | |
with: | |
host: ${{secrets.EC2_DEV_HOST}} | |
username: ec2-user | |
key: ${{secrets.EC2_DEV_PRIVATE_KEY}} | |
port: 22 | |
envs: APP, COMPOSE | |
script_stop: true | |
script: | | |
docker-compose -f $COMPOSE down | |
docker pull ${{ secrets.DOCKER_ID }}/backgu:dev | |
docker-compose -f $COMPOSE up -d | |