Update README.md #24
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: 🎇 Deployer | |
on: | |
push: | |
branches: [ 'main' ] | |
pull_request: | |
branches: [ 'main' ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: CI | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout java code | |
uses: actions/checkout@v3 | |
- name: Set up Jdk 11 ver | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
- name: Gradle Caching | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*','**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Grant execute Permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
- name: Login to Dockerhub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{secrets.DOCKER_USERNAME}} | |
password: ${{secrets.DOCKER_PASSWORD}} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker build & push to DockerHub | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/better-iter:latest | |
deploy: | |
name: CD | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Connect to WAS & Execute Application | |
uses: appleboy/ssh-action@v0.1.6 | |
with: | |
host: ${{ secrets.HOST_IP }} | |
username: ${{ secrets.USERNAME }} | |
port: 22 | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: | | |
docker -v | |
docker ps | |
docker stop $(docker ps -aq) | |
docker rm $(docker ps -aq) | |
docker image rm $(docker images -q) | |
docker pull ${{ secrets.DOCKER_USERNAME }}/better-iter:latest | |
docker run -d -p 8080:8080 --name ${{ secrets.CONTAINER_NAME }} --env-file .env ${{ secrets.DOCKER_USERNAME }}/better-iter:latest | |
docker ps | |