Skip to content

Fix: github-actions.yml 수정 #59

Fix: github-actions.yml 수정

Fix: github-actions.yml 수정 #59

name: CI/CD with docker
on:
push:
branches: ["develop"]
permissions:
contents: read
jobs:
CI-CD:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Make application.properties
run: |
mkdir -p ./src/main/resources
touch ./src/main/resources/application.properties
echo "${{ secrets.PROPERTIES }}" > ./src/main/resources/application.properties
cat ./src/main/resources/application.properties
shell: bash
- name: Build with Gradle
run: |
sudo chmod +x gradlew
./gradlew build -x test
- name: Docker build & push to prod
if: contains(github.ref, 'develop')
run: |
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
sudo docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/cherry_code .
sudo docker push ${{ secrets.DOCKER_USERNAME }}/cherry_code
- name: Deploy Images with Docker compose
uses: appleboy/ssh-action@master
with:
username: ubuntu
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
sudo docker ps
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/cherry_code
sudo docker run -d --network cherryCode_network -p 8080:8080 --protocol=tcp ${{ secrets.DOCKER_USERNAME }}/cherry_code
sudo docker image prune -f