infra: main-deploy.yml #10
This file contains hidden or 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: Java CI/CD with Gradle and Docker | |
| # | |
| #on: | |
| # push: | |
| # branches: main | |
| # | |
| #jobs: | |
| # build: | |
| # runs-on: ubuntu-latest | |
| # steps: | |
| # - uses: actions/checkout@v4 | |
| # | |
| # # JDK Setting | |
| # - name: Set up JDK 17 | |
| # uses: actions/setup-java@v4 | |
| # with: | |
| # java-version: '17' | |
| # distribution: 'temurin' | |
| # | |
| # # Generate application-prod.yml | |
| # - name: generate application-prod.yml | |
| # env: | |
| # APPLICATION_PROD: ${{ secrets.APPLICATION_PROD }} | |
| # run: | | |
| # echo $APPLICATION_PROD | base64 --decode > src/main/resources/application-prod.yml | |
| # | |
| # # Grant execute permission for gradlew | |
| # - name: Grant execute permission for gradlew | |
| # run: chmod +x gradlew | |
| # | |
| # - name: Build with Gradle (without test) | |
| # run: ./gradlew clean build -x test --stacktrace | |
| # | |
| # ######## CD(Continuous Deployment) ######## | |
| # - name: Docker build & push to repository | |
| # if: contains(github.ref, 'main') | |
| # run: | | |
| # docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_PASSWORD }}" | |
| # docker build -f Dockerfile -t "${{ secrets.DOCKER_USERNAME }}"/talent-trade . | |
| # docker push "${{ secrets.DOCKER_USERNAME }}"/talent-trade | |
| # | |
| # # Deploy | |
| # - name: Deploy to EC2 | |
| # uses: appleboy/ssh-action@v0.1.6 | |
| # with: | |
| # host: ${{ secrets.HOST_DOMAIN }} | |
| # username: ${{ secrets.HOST_USERNAME }} | |
| # key: ${{ secrets.PRIVATE_KEY }} | |
| # script: | | |
| # docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_PASSWORD }}" | |
| # docker stop $(docker ps -a -q) | |
| # docker rm $(docker ps -a -q) | |
| # docker pull "${{ secrets.DOCKER_USERNAME }}"/talent-trade:latest | |
| # docker compose up -d | |
| # docker image prune -a -f |