Merge: Develop Branch 와 병합 #30
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: Github Actions Workflow | |
on: | |
push: | |
branches: [ main ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: gaseng 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: 'adopt' | |
- name: Set .yml for main | |
run: | | |
cd ./src/main/resources | |
touch ./application.yaml | |
echo "${{ secrets.MAIN_YML }}" >> ./application.yml | |
shell: bash | |
- name: Build with Gradle | |
run: | | |
chmod +x ./gradlew | |
./gradlew clean build -x test | |
- name: Docker build & push to docker repo | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/gaseng . | |
docker push ${{ secrets.DOCKER_USERNAME }}/gaseng | |
- 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 rm -f $(docker ps -qa) | |
docker rmi ${{ secrets.DOCKER_USERNAME }}/gaseng | |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/gaseng | |
sudo chmod -R 755 /root/docker | |
sudo docker-compose -f "/root/docker/docker-compose.yml" up -d | |
docker image prune -f |