🐛 fix the problem of static in resources folder #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: CI/CD Pipeline | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Slack commit message and sha | |
run: > | |
curl -X POST -H 'Content-type: application/json' | |
--data '{"text":":github: https://github.com/miliariadnane/herb-classifier-api/commit/${{ github.sha }} - ${{ github.event.head_commit.message }}"}' | |
${{ secrets.SLACK_WEBHOOK_URL }} | |
- name: Send Slack Message | |
run: > | |
curl -X POST -H 'Content-type: application/json' | |
--data '{"text":"Deployment started :progress_bar: :fingerscrossed:"}' | |
${{ secrets.SLACK_WEBHOOK_URL }} | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'maven' | |
- name: Set build version number | |
id: build-version | |
run: echo "BUILD_VERSION=$(date '+%d.%m.%Y.%H.%M.%S')" >> $GITHUB_ENV | |
- name: Send Slack Message | |
run: > | |
curl -X POST -H 'Content-type: application/json' | |
--data '{"text":":maven: Build project with Maven"}' | |
${{ secrets.SLACK_WEBHOOK_URL }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Build Docker image | |
run: docker build . --file Dockerfile --tag miliariadnane/herb-classifier-api:${{ env.BUILD_VERSION }} | |
- name: Push Docker image | |
run: docker push miliariadnane/herb-classifier-api:${{ env.BUILD_VERSION }} | |
- name: Send Slack Message | |
run: > | |
curl -X POST -H 'Content-type: application/json' | |
--data '{"text":":docker: Image tag:${{ env.BUILD_VERSION }} pushed to dockerhub in https://hub.docker.com/repository/docker/miliariadnane/herb-classifier-api"}' | |
${{ secrets.SLACK_WEBHOOK_URL }} | |
- uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Disable ssh strict host checking | |
run: | | |
echo "StrictHostKeyChecking no" >> ~/.ssh/config | |
- name: SSH and Deploy Docker image | |
run: | | |
docker -H=ssh://${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} pull miliariadnane/herb-classifier-api:${{ env.BUILD_VERSION }} || exit 1 | |
CONTAINER_ID=$(docker -H=ssh://${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} ps -q --filter ancestor=miliariadnane/herb-classifier-api) | |
if [ "$CONTAINER_ID" != "" ]; then | |
docker -H=ssh://${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} stop $CONTAINER_ID || true | |
fi | |
docker -H=ssh://${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} run -d -p 80:80 miliariadnane/herb-classifier-api:${{ env.BUILD_VERSION }} || exit 1 | |
- name: Send Slack Message | |
run: > | |
curl -X POST -H 'Content-type: application/json' | |
--data '{"text":"Deployment and commit completed :github-check-mark: :party_blob: - http://130.61.32.252:32768/api/v1/herb-classifier/service/"}' | |
${{ secrets.SLACK_WEBHOOK_URL }} | |
- name: Send Slack Message | |
if: always() | |
run: > | |
curl -X POST -H 'Content-type: application/json' | |
--data '{"text":"Job Status ${{ job.status }}"}' | |
${{ secrets.SLACK_WEBHOOK_URL }} |