Merge pull request #39 from syyling/feat/34 #36
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: cd | |
on: | |
push: | |
branches: | |
- dev | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Gradle Caching | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Make application-prod.yml | |
run: | | |
cd ./src/main/resources | |
touch ./application-prod.yml | |
echo "${{ secrets.APPLICATION_PROD }}" > ./application-prod.yml | |
shell: bash | |
- name: Grant Execute Permission For Gradlew | |
run: chmod +x gradlew | |
- name: Build With Gradle | |
run: ./gradlew build | |
- name: Docker build & push to docker repo | |
env: | |
DOCKER_PATH : .deploy/Dockerfile | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -f $DOCKER_PATH -t ${{ secrets.DOCKER_REPO }}/mookive . | |
docker push ${{ secrets.DOCKER_REPO }}/mookive | |
- name: Deploy to Prob | |
uses: appleboy/ssh-action@master | |
id: deploy-prob | |
env: | |
DOCKER_COMPOSE : ".deploy/docker-compose.yml" | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ubuntu | |
key: ${{ secrets.EC2_KEY }} | |
envs: GITHUB_SHA | |
script: | | |
touch ./docker-compose.yml | |
echo "${{ secrets.DOCKER_COMPOSE }}" > ./docker-compose.yml | |
docker stop mookive | |
docker rm mookive | |
docker pull ${{ secrets.DOCKER_REPO }}/mookive | |
docker-compose up -d | |
docker image prune |