-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created deploy steps at deploy workflow
- Loading branch information
1 parent
e25ca89
commit 6dfbd85
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |