Merge pull request #122 from OMZigak/develop #7
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: prod-CD | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request_target: | |
types: [ labeled, closed ] | |
jobs: | |
ci: | |
if: contains(github.event.pull_request.labels.*.name, 'deploy') | |
runs-on: ubuntu-22.04 | |
env: | |
working-directory: . | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
token: ${{ secrets.SUBMODULE_TOKEN }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: '17' | |
- name: build | |
run: | | |
chmod +x gradlew | |
./gradlew build -x test | |
shell: bash | |
- name: docker login | |
uses: docker/[email protected] | |
- name: login docker hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_LOGIN_USERNAME }} | |
password: ${{ secrets.DOCKER_LOGIN_ACCESSTOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile-prod | |
push: true | |
tags: ${{ secrets.DOCKER_LOGIN_USERNAME }}/${{ secrets.PROD_REPONAME }} | |
cd: | |
needs: ci | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: docker container run | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.PROD_SERVER_IP }} | |
username: ${{ secrets.PROD_SERVER_USER }} | |
key: ${{ secrets.PROD_SERVER_KEY }} | |
script: | | |
cd ~ | |
./deploy.sh |