-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd2ddc5
commit b69a7c2
Showing
2 changed files
with
50 additions
and
34 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 |
---|---|---|
@@ -1,39 +1,55 @@ | ||
name: Master branch deploy | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
jobs: | ||
build: | ||
name: Build image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- run: docker login ghcr.io -u $GITHUB_ACTOR -p ${{ secrets.GHCR_TOKEN }} | ||
- run: docker build -t ghcr.io/$GITHUB_ACTOR/infomate:latest -t ghcr.io/$GITHUB_ACTOR/walter:$GITHUB_SHA . | ||
- run: docker image push ghcr.io/$GITHUB_ACTOR/walter:$GITHUB_SHA | ||
- run: docker image push ghcr.io/$GITHUB_ACTOR/walter:latest | ||
build: | ||
name: Build image | ||
runs-on: ubuntu-latest | ||
environment: production | ||
steps: | ||
- uses: actions/checkout@master | ||
- run: docker login ghcr.io -u $GITHUB_ACTOR -p ${{ secrets.GHCR_TOKEN }} | ||
- run: docker build -f ./infra/production/django/Dockerfile -t ghcr.io/$GITHUB_ACTOR/walter:latest -t ghcr.io/$GITHUB_ACTOR/walter:$GITHUB_SHA . | ||
- run: docker image push ghcr.io/$GITHUB_ACTOR/walter:$GITHUB_SHA | ||
- run: docker image push ghcr.io/$GITHUB_ACTOR/walter:latest | ||
|
||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
needs: build | ||
env: | ||
SSH_KEY_PATH: /tmp/ssh_key | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Make envfile | ||
run: export | grep "secret_" | sed "s/declare -x secret_//" > .env | ||
env: | ||
SECRET_KEY: ${{ secrets.SECRET_KEY }} | ||
APP_HOST: ${{ env.APP_HOST }} | ||
- run: echo "GITHUB_SHA=$GITHUB_SHA" >> .env | ||
- run: echo "${{ secrets.PRODUCTION_SSH_KEY }}" > ${{ env.SSH_KEY_PATH }} && chmod 600 ${{ env.SSH_KEY_PATH }} | ||
- run: scp -o StrictHostKeyChecking=no -i ${{ env.SSH_KEY_PATH }} -r $(pwd)/* ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }}:/home/walter/walter | ||
- run: scp -o StrictHostKeyChecking=no -i ${{ env.SSH_KEY_PATH }} .env ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }}:/home/walter/walter/.env | ||
- run: scp -o StrictHostKeyChecking=no -i ${{ env.SSH_KEY_PATH }} docker-compose.production.yml ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }}:/home/walter/walter/docker-compose.prod.yml | ||
- run: ssh -i ${{ env.SSH_KEY_PATH }} ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }} "cd /home/walter/walter && docker login ghcr.io -u $GITHUB_ACTOR -p ${{ secrets.GHCR_TOKEN }} && docker pull ghcr.io/$GITHUB_ACTOR/walter:$GITHUB_SHA && docker-compose -f docker-compose.prod.yml --env-file=.env up -d && docker system prune --all --force" | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
environment: production | ||
needs: build | ||
env: | ||
SSH_KEY_PATH: /tmp/ssh_key | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Make envfile | ||
run: export | grep "secret_" | sed "s/declare -x secret_//" > .env | ||
env: | ||
secret_SECRET_KEY: ${{ secrets.SECRET_KEY }} | ||
secret_DJANGO_ALLOWED_HOSTS: ${{ env.DJANGO_ALLOWED_HOSTS }} | ||
secret_DEBUG: ${{ env.DEBUG }} | ||
secret_SQL_ENGINE: ${{ env.SQL_ENGINE }} | ||
secret_SQL_DATABASE: ${{ env.SQL_DATABASE }} | ||
secret_SQL_USER: ${{ secrets.SQL_USER }} | ||
secret_SQL_PASSWORD: ${{ secrets.SQL_PASSWORD }} | ||
secret_SQL_HOST: ${{ env.SQL_HOST }} | ||
secret_SQL_PORT: ${{ env.SQL_HOST }} | ||
secret_RABBITMQ_DEFAULT_USER: ${{ secrets.RABBITMQ_DEFAULT_USER }} | ||
secret_RABBITMQ_DEFAULT_PASS: ${{ secrets.RABBITMQ_DEFAULT_PASS }} | ||
secret_CELERY_BROKER: ${{ env.CELERY_BROKER }} | ||
secret_CELERY_BACKEND: ${{ env.CELERY_BACKEND }} | ||
secret_CELERY_FLOWER_USER: ${{ secrets.CELERY_FLOWER_USER }} | ||
secret_CELERY_FLOWER_PASSWORD: ${{ secrets.CELERY_FLOWER_PASSWORD }} | ||
secret_CHANNELS_REDIS: ${{ env.CHANNELS_REDIS }} | ||
- run: echo "GITHUB_SHA=$GITHUB_SHA" >> .env | ||
- run: echo "${{ secrets.PRODUCTION_SSH_KEY }}" > ${{ env.SSH_KEY_PATH }} && chmod 600 ${{ env.SSH_KEY_PATH }} | ||
- run: scp -o StrictHostKeyChecking=no -i ${{ env.SSH_KEY_PATH }} -r $(pwd)/* ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }}:/home/walter/walter | ||
- run: scp -o StrictHostKeyChecking=no -i ${{ env.SSH_KEY_PATH }} .env ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }}:/home/walter/walter/.env | ||
- run: scp -o StrictHostKeyChecking=no -i ${{ env.SSH_KEY_PATH }} docker-compose.prod.yml ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }}:/home/walter/walter/docker-compose.prod.yml | ||
- run: ssh -i ${{ env.SSH_KEY_PATH }} ${{ secrets.PRODUCTION_SSH_USERNAME }}@${{ secrets.PRODUCTION_SSH_HOST }} "cd /home/walter/walter && docker login ghcr.io -u $GITHUB_ACTOR -p ${{ secrets.GHCR_TOKEN }} && docker pull ghcr.io/$GITHUB_ACTOR/walter:$GITHUB_SHA && docker compose -f docker-compose.prod.yml --env-file=.env up -d && docker system prune --all --force" |
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