Update github-actions.yml 네트워크 연결 #38
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 with docker-compose | |
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.yml | |
run: | | |
mkdir ./src/main/resources | |
cd ./src/main/resources | |
touch ./application.properties | |
echo "${{ secrets.PROPERTIES }}" > ./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: | | |
docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_PASSWORD}} | |
docker build -f Dockerfile -t ${{secrets.DOCKER_USERNAME}}/cherry_code . | |
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 -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/cherry_code --network cherryCode_network | |
sudo docker image prune -f |