feat: added blog management #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: Deploy | |
on: | |
push: | |
branches: | |
- development | |
- production | |
env: | |
DOCKER_PROJECT_NAME_DEV: dev-orgatrips-back | |
PROJECT_PATH_DEV: ${{ secrets.DEVELOPMENT_DOCKER_IMAGES_PATH }}/dev-orgatrips-back | |
DOCKER_PROJECT_NAME_PROD: orgatrips-back | |
PROJECT_PATH_PROD: ${{ secrets.PRODUCTION_DOCKER_IMAGES_PATH }}/orgatrips-back | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Extract branch name | |
shell: bash | |
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/} | tr a-z A-Z)" | |
id: extract_branch | |
- name: Create .env | |
run: | | |
touch .env | |
echo "APP_SECRET=${{ secrets.APP_SECRET }}" >> .env | |
echo "APP_MAILJET_PUBLIC_KEY=${{ secrets.APP_MAILJET_PUBLIC_KEY }}" >> .env | |
echo "APP_MAILJET_PRIVATE_KEY=${{ secrets.APP_MAILJET_PRIVATE_KEY }}" >> .env | |
echo "APP_MAILJET_SENDER_MAIL=${{ secrets.APP_MAILJET_SENDER_MAIL }}" >> .env | |
echo "APP_KIWI_PUBLIC_KEY=${{ secrets.APP_KIWI_PUBLIC_KEY }}" >> .env | |
echo "APP_CORS_ORIGIN=${{ secrets.APP_CORS_ORIGIN }}" >> .env | |
- name: Add .env variable based on branch development | |
if: ${{ steps.extract_branch.outputs.branch == 'DEVELOPMENT' }} | |
run: | | |
echo "APP_DB_HOST=${{ secrets.DEVELOPMENT_APP_DB_HOST }}" >> .env | |
echo "APP_DB_USER=${{ secrets.DEVELOPMENT_APP_DB_USER }}" >> .env | |
echo "APP_DB_PASSWORD=${{ secrets.DEVELOPMENT_APP_DB_PASSWORD }}" >> .env | |
echo "APP_DB_NAME=${{ secrets.DEVELOPMENT_APP_DB_NAME }}" >> .env | |
echo "APP_BACKEND_PUBLIC_URL=${{ secrets.DEVELOPMENT_APP_BACKEND_PUBLIC_URL }}" >> .env | |
echo "APP_FRONTEND_PUBLIC_URL=${{ secrets.DEVELOPMENT_APP_FRONTEND_PUBLIC_URL }}" >> .env | |
echo "APP_TRANSPORTATION_BUDGET_PERCENTAGE=${{ secrets.DEVELOPMENT_APP_TRANSPORTATION_BUDGET_PERCENTAGE }}" >> .env | |
echo "APP_ACCOMODATION_BUDGET_PERCENTAGE=${{ secrets.DEVELOPMENT_APP_ACCOMODATION_BUDGET_PERCENTAGE }}" >> .env | |
echo "APP_OTHER_BUDGET_PER_DAY=${{ secrets.DEVELOPMENT_APP_OTHER_BUDGET_PER_DAY }}" >> .env | |
- name: Add .env variable based on branch development | |
if: ${{ steps.extract_branch.outputs.branch == 'PRODUCTION' }} | |
run: | | |
echo "APP_DB_HOST=${{ secrets.PRODUCTION_APP_DB_HOST }}" >> .env | |
echo "APP_DB_USER=${{ secrets.PRODUCTION_APP_DB_USER }}" >> .env | |
echo "APP_DB_PASSWORD=${{ secrets.PRODUCTION_APP_DB_PASSWORD }}" >> .env | |
echo "APP_DB_NAME=${{ secrets.PRODUCTION_APP_DB_NAME }}" >> .env | |
echo "APP_BACKEND_PUBLIC_URL=${{ secrets.PRODUCTION_APP_BACKEND_PUBLIC_URL }}" >> .env | |
echo "APP_FRONTEND_PUBLIC_URL=${{ secrets.PRODUCTION_APP_FRONTEND_PUBLIC_URL }}" >> .env | |
echo "APP_TRANSPORTATION_BUDGET_PERCENTAGE=${{ secrets.PRODUCTION_APP_TRANSPORTATION_BUDGET_PERCENTAGE }}" >> .env | |
echo "APP_ACCOMODATION_BUDGET_PERCENTAGE=${{ secrets.PRODUCTION_APP_ACCOMODATION_BUDGET_PERCENTAGE }}" >> .env | |
echo "APP_OTHER_BUDGET_PER_DAY=${{ secrets.PRODUCTION_APP_OTHER_BUDGET_PER_DAY }}" >> .env | |
- name: Use Node.js 14.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "14.x" | |
cache: "yarn" | |
- name: Install dependencies | |
run: yarn install | |
# DEVELOPMENT | |
- name: Copy repository contents via scp | |
if: ${{ steps.extract_branch.outputs.branch == 'DEVELOPMENT' }} | |
uses: appleboy/scp-action@master | |
with: | |
HOST: ${{ secrets.DEVELOPMENT_HOST }} | |
USERNAME: ${{ secrets.DEVELOPMENT_USERNAME }} | |
PORT: ${{ secrets.DEVELOPMENT_PORT }} | |
KEY: ${{ secrets.DEVELOPMENT_SSHKEY }} | |
source: "." | |
target: ${{ env.PROJECT_PATH_DEV }} | |
- name: Executing remote command | |
if: ${{ steps.extract_branch.outputs.branch == 'DEVELOPMENT' }} | |
uses: appleboy/ssh-action@master | |
with: | |
HOST: ${{ secrets.DEVELOPMENT_HOST }} | |
USERNAME: ${{ secrets.DEVELOPMENT_USERNAME }} | |
PORT: ${{ secrets.DEVELOPMENT_PORT }} | |
KEY: ${{ secrets.DEVELOPMENT_SSHKEY }} | |
envs: PROJECT_PATH_DEV,DOCKER_PROJECT_NAME_DEV | |
script: | | |
cd $PROJECT_PATH_DEV | |
git clean -df | |
docker ps -q --filter "name=$DOCKER_PROJECT_NAME_DEV" | grep -q . && docker stop $DOCKER_PROJECT_NAME_DEV && docker container rm $DOCKER_PROJECT_NAME_DEV | |
docker build -t $DOCKER_PROJECT_NAME_DEV $PROJECT_PATH_DEV | |
docker run -d --network reverse-proxy --ip ${{ secrets.DEVELOPMENT_DOCKER_LOCAL_IP }} --name $DOCKER_PROJECT_NAME_DEV -t $DOCKER_PROJECT_NAME_DEV | |
# PRODUCTION | |
- name: Copy repository contents via scp PRODUCTION | |
if: ${{ steps.extract_branch.outputs.branch == 'PRODUCTION' }} | |
uses: appleboy/scp-action@master | |
with: | |
HOST: ${{ secrets.PRODUCTION_HOST }} | |
USERNAME: ${{ secrets.PRODUCTION_USERNAME }} | |
PORT: ${{ secrets.PRODUCTION_PORT }} | |
KEY: ${{ secrets.PRODUCTION_SSHKEY }} | |
source: "." | |
target: ${{ env.PROJECT_PATH_PROD }} | |
- name: Executing remote command PRODUCTION | |
if: ${{ steps.extract_branch.outputs.branch == 'PRODUCTION' }} | |
uses: appleboy/ssh-action@master | |
with: | |
HOST: ${{ secrets.PRODUCTION_HOST }} | |
USERNAME: ${{ secrets.PRODUCTION_USERNAME }} | |
PORT: ${{ secrets.PRODUCTION_PORT }} | |
KEY: ${{ secrets.PRODUCTION_SSHKEY }} | |
envs: PROJECT_PATH_PROD,DOCKER_PROJECT_NAME_PROD | |
script: | | |
cd $PROJECT_PATH_PROD | |
git clean -df | |
docker ps -q --filter "name=$DOCKER_PROJECT_NAME_PROD" | grep -q . && docker stop $DOCKER_PROJECT_NAME_PROD && docker container rm $DOCKER_PROJECT_NAME_PROD | |
docker build -t $DOCKER_PROJECT_NAME_PROD $PROJECT_PATH_PROD | |
docker run -d --network reverse-proxy --ip ${{ secrets.PRODUCTION_DOCKER_LOCAL_IP }} --name $DOCKER_PROJECT_NAME_PROD -t $DOCKER_PROJECT_NAME_PROD |