-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
29 additions
and
36 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 |
---|---|---|
|
@@ -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 . | ||
|
@@ -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 ####" | ||
|
@@ -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: | ||
|
||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 |