Skip to content

Commit

Permalink
Update ci-cd.yml
Browse files Browse the repository at this point in the history
ajuste pytest database postgres
  • Loading branch information
luizhpriotto authored Nov 25, 2022
1 parent 74bc59d commit 363626f
Showing 1 changed file with 29 additions and 36 deletions.
65 changes: 29 additions & 36 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ jobs:

- uses: actions/checkout@v2

- name: Delete Container..
run: if [ ! -z $(docker ps -q --filter "name=ptrf-db") ]; then docker rm -f ptrf-db; fi

- name: Set env
run: echo "GITHUB_RUN_ID_SHORT=$(echo $GITHUB_RUN_ID | cut -c 1-6)" >> $GITHUB_ENV

- name: Test
run: echo $GITHUB_RUN_ID_SHORT

- name: Delete Container..
run: if [ ! -z $(docker ps -q --filter "name=ptrf-db$GITHUB_RUN_ID_SHORT") ]; then docker rm -f ptrf-db$GITHUB_RUN_ID_SHORT; fi

- name: Preparing Container...
#Criação do container de banco de dados e copia das variaveis que serão carregadas.
run: |
docker run -d --rm --cap-add SYS_TIME --name ptrf-db -p 5432 --network python-network -e TZ="America/Sao_Paulo" -e POSTGRES_DB=ptrf -e POSTGRES_PASSWORD=adminadmin -e POSTGRES_USER=postgres postgres:11-alpine
docker run -d --rm --cap-add SYS_TIME --name ptrf-db$GITHUB_RUN_ID_SHORT -p 5432 --network python-network -e TZ="America/Sao_Paulo" -e POSTGRES_DB=ptrf -e POSTGRES_PASSWORD=adminadmin -e POSTGRES_USER=postgres postgres:11-alpine
echo "copiando fontes..."
cp /srv/env/ptrf .
Expand All @@ -37,6 +42,7 @@ jobs:
docker network connect python-network $(hostname)
echo "Carregando as variaveis de ambiente..."
source ptrf
export POSTGRES_HOST=ptrf-db$GITHUB_RUN_ID_SHORT
pip install --user pipenv -r requirements/local.txt
python manage.py collectstatic --noinput
echo "##### COVERAGE ####"
Expand All @@ -52,7 +58,7 @@ jobs:

- name: Delete Container..
if: ${{ ( failure() ) || ( success() ) }}
run: if [ ! -z $(docker ps -q --filter "name=ptrf-db") ]; then docker rm -f ptrf-db; fi
run: if [ ! -z $(docker ps -q --filter "name=ptrf-db$GITHUB_RUN_ID_SHORT") ]; then docker rm -f ptrf-db$GITHUB_RUN_ID_SHORT; fi

sonar:

Expand Down Expand Up @@ -152,21 +158,7 @@ jobs:
RANCHER_TOKEN: ${{ secrets.RANCHER_TOKEN }}
NAMESPACE: sme-ptrf-hom2
WORKLOAD: ptrf-backend,ptrf-celery,ptrf-flower

- name: send failure message
if: ${{ failure() }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
💥 Failed in ${{ github.ref_name }}!
${{ github.actor }} created commit:
Commit message: ${{ github.event.commits[0].message }}
Repository: ${{ github.repository }}
See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}}
Actions: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

deploy-k8s-dev:

runs-on: self-hosted
Expand All @@ -183,21 +175,7 @@ jobs:
RANCHER_TOKEN: ${{ secrets.RANCHER_TOKEN }}
NAMESPACE: sme-ptrf
WORKLOAD: ptrf-backend,ptrf-celery,ptrf-flower

- name: send failure message
if: ${{ failure() }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
💥 Failed in ${{ github.ref_name }}!
${{ github.actor }} created commit:
Commit message: ${{ github.event.commits[0].message }}
Repository: ${{ github.repository }}
See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}}
Actions: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

deploy-k8s-prod:

runs-on: self-hosted
Expand Down Expand Up @@ -252,4 +230,19 @@ jobs:
Repository: ${{ github.repository }}
See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}}
Actions: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
deploy-k8s-pre-prod:

runs-on: self-hosted
needs: [ build,sonar ]
if: ${{ github.ref == 'refs/heads/pre-prod' }}
environment:
name: production
steps:

- name: Redeploy Pre Prod
uses: luizhpriotto/[email protected]
env:
RANCHER_URL: ${{ secrets.RANCHER_URL }}
RANCHER_TOKEN: ${{ secrets.RANCHER_TOKEN }}
NAMESPACE: sme-sigescola-pre

0 comments on commit 363626f

Please sign in to comment.