Update gradle.yml #3
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | |
name: Java CI with Gradle | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. 최신 이미지를 풀받습니다 | |
- name: docker pull | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/se-community-image | |
# 2. 기존의 컨테이너를 중지시킵니다 | |
- name: docker stop container | |
run: sudo docker stop $(sudo docker ps -q) 2>/dev/null || true | |
# 3. 최신 이미지를 컨테이너화하여 실행시킵니다 | |
- name: docker run new container | |
run: sudo docker run --name se-community-image --rm -d -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/se-community-image | |
# 4. 미사용 이미지를 정리합니다 | |
- name: delete old docker image | |
run: sudo docker system prune -f |