Update gradle.yml #6
Workflow file for this run
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: CICD | |
on: | |
push: | |
branches: [deploy-to-ec2] | |
jobs: | |
build: | |
runs-on: [ubuntu-latest] | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
- name: login to docker hub | |
run: docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_PASSWORD}} | |
- name: Build docker image | |
run: docker build -t glass77109/beep . | |
- name: Publish image to docker hub | |
run: docker push glass77109/beep:latest | |
deploy: | |
needs: build | |
runs-on: [aws-ec2] | |
steps: | |
- name: Pull Image From Docker hub | |
run: docker pull install glass77109/beep:latest | |
- name: Delete old container | |
run: docker rm -f beep-container | |
- name: Run docker container | |
run: docker run -d -p 8080:8080 -e SPRING_PROFILES_ACTIVE=prod --name beep-container glass77109/beep |