[IL-286] Average Rating, Review Exists Check #203
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: Build and Deploy | |
on: | |
pull_request: | |
types: [ closed ] | |
env: | |
ENV_FILE_NAME: .backend_env | |
DOCKER_COMPOSE_FILE: docker-compose.yml | |
DOCKER_CONTAINER_NAME: latte-backend | |
DOCKER_IMAGE_NAME: iced-latte-backend | |
DOCKER_HUB_ACCOUNT_NAME: zufarexplainedit | |
APP_PATH_ON_THE_REMOTE_SERVER: /opt/project/Iced-Latte | |
jobs: | |
build-and-push-docker-image: | |
name: Build and push docker image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code from the repository | |
uses: actions/checkout@v4 | |
- name: Set DOCKER_IMAGE_TAG | |
run: echo "DOCKER_IMAGE_TAG=$GITHUB_REF_NAME-${GITHUB_SHA:0:7}" >> $GITHUB_ENV | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKER_HUB_ACCOUNT_NAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Build and push docker image | |
run: | | |
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} build | |
docker push ${{ env.DOCKER_HUB_ACCOUNT_NAME }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG }} | |
deploy-app-to-server: | |
name: Deploy application to remote server via ssh | |
runs-on: ubuntu-latest | |
needs: build-and-push-docker-image | |
steps: | |
- name: Set DOCKER_IMAGE_TAG | |
run: echo "DOCKER_IMAGE_TAG=$GITHUB_REF_NAME-${GITHUB_SHA:0:7}" >> $GITHUB_ENV | |
- name: Deploy image via SSH | |
uses: appleboy/[email protected] | |
env: | |
DOCKER_IMAGE_TAG: ${{ env.DOCKER_IMAGE_TAG }} | |
with: | |
host: ${{ secrets.DEV_SSH_HOST }} | |
port: ${{ secrets.DEV_SSH_PORT }} | |
username: ${{ secrets.DEV_SSH_USER }} | |
key: ${{ secrets.DEV_SSH_PRIV_KEY }} | |
envs: DOCKER_IMAGE_TAG | |
script: | | |
cd ${{ env.APP_PATH_ON_THE_REMOTE_SERVER }} | |
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} down ${{ env.DOCKER_CONTAINER_NAME }} | |
docker-compose -f ${{ env.DOCKER_COMPOSE_FILE }} up -d ${{ env.DOCKER_CONTAINER_NAME }} |