Skip to content

Commit

Permalink
created deploy steps at deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan-Skvortsov committed Aug 15, 2023
1 parent e25ca89 commit 6dfbd85
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/deploy_stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,54 @@ jobs:
${{ env.REGISTRY }}/${{ env.REP_OWNER }}/${{ env.IMAGE_NAME }}:stage,
${{ env.REGISTRY }}/${{ env.REP_OWNER }}/${{ env.IMAGE_NAME }}:latest,
${{ env.REGISTRY }}/${{ env.REP_OWNER }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
deploy:
name: Deploy
# if: github.event.pull_request.merged == true
runs-on: ubunut-latest
needs: buld_and_push_image_to_github_packages
environment:
name: Stage

steps:
-
name: Check out the repo
uses: actions/checkout@v3
-
name: Copy docker-compose and nginx files to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
source: "infra/docker-compose.stage.yaml,infra/nginx/nginx.stage.conf"
target: ${{ env.DEPLOY_PATH }}
-
name: Execute remote commands to deploy and start app
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
script: |
cd ${{ env.DEPLOY_PATH }}
rm -f .env
touch .env
echo DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }} >> .env
echo DJANGO_ALLOWED_HOSTS=${{ secrets.DJANGO_ALLOWED_HOSTS }} >> .env
echo CSRF_TRUSTED_ORIGINS=${{ secrets.CSRF_TRUSTED_ORIGINS }} >> .env
echo DJANGO_DEBUG=${{ secrets.DJANGO_DEBUG }} >> .env
echo POSTGRES_DB=${{ secrets.POSTGRES_DB }} >> .env
echo POSTGRES_USER=${{ secrets.POSTGRES_USER }} >> .env
echo POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} >> .env
echo POSTGRES_HOST=${{ secrets.POSTGRES_HOST }} >> .env
echo POSTGRES_PORT=${{ secrets.POSTGRES_PORT }} >> .env
sudo docker image prune -f
sudo docker pull ${{ env.REGISTRY }}/${{ env.REP_OWNER }}/${{ env.IMAGE_NAME }}:latest
sudo docker-compose --file infra/docker-compose.stage.yaml stop
sudo docker-compose --file infra/docker-compose.stage.yaml rm backend
sudo docker-compose --file infra/docker-compose.stage.yaml up -d

0 comments on commit 6dfbd85

Please sign in to comment.