추가: docker 고침 #49
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: CD with Gradle | |
on: | |
push: | |
branches: [ "develop" ] | |
pull_request: | |
branches: [ "develop" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: "adopt" | |
- name: Build with Gradle | |
run: | | |
chmod +x ./gradlew | |
./gradlew clean build -x test | |
- name: create firebase key | |
run: | | |
cd ./src/main/resources | |
echo pwd | |
ls -a . | |
touch ./firebase-service-key.json | |
echo "${{ secrets.FIREBASE_KEY }}" > ./firebase-service-key.json | |
shell: bash | |
- name: Docker build & push to docker repo | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/ticats . | |
docker push ${{ secrets.DOCKER_USERNAME }}/ticats | |
- name: Deploy to server | |
uses: appleboy/ssh-action@master | |
id: deploy | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.KEY }} | |
envs: GITHUB_SHA | |
script: | | |
sudo docker stop ticats | |
sudo docker rm ticats | |
sudo docker image rm gabang2/ticats:latest | |
sudo docker pull gabang2/ticats:latest | |
sudo docker run -d -p 8080:8080 --name ticats ${{ secrets.ENVS }} gabang2/ticats:latest |