Skip to content

Merge pull request #35 from YAPP-Github/fix/PC-440-confict-fix #3

Merge pull request #35 from YAPP-Github/fix/PC-440-confict-fix

Merge pull request #35 from YAPP-Github/fix/PC-440-confict-fix #3

Workflow file for this run

name: CI/CD using github actions & docker
on:
push:
branches: [ "main", "develope" ]
permissions:
contents: read
jobs:
CI-CD:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
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-
# secret yml 파일 생성
- name: make application-secret.yml
if: |
contains(github.ref, 'main') ||
contains(github.ref, 'develope')
run: |
cd ./api/src/main/resources
touch ./application-secret.yml
echo "${{ secrets.YML }}" > ./application-secret.yml
shell: bash
# gradle build
- name: Build with Gradle
run: |
chmod u+x ./gradlew
./gradlew build -x test
# docker build & push to develop
- name: Docker build & push to dev
if: contains(github.ref, 'develope')
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile-dev -t ${{ secrets.DOCKER_USERNAME }}/docker-test-dev .
docker push ${{ secrets.DOCKER_USERNAME }}/docker-test-dev
## deploy to develop
- name: Deploy to dev
uses: appleboy/ssh-action@master
id: deploy-dev
if: contains(github.ref, 'develope')
with:
host: ${{ secrets.HOST_DEV }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: 22
key: ${{ secrets.PRIVATE_KEY }}
script: |
sudo docker ps
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/docker-test-dev
sudo docker run -d -p 8080:8080 --network piece-nw ${{ secrets.DOCKER_USERNAME }}/docker-test-dev
sudo docker image prune -f