Sonar and gitea settings
Some checks failed
Build / Code quality (push) Failing after 25s

This commit is contained in:
2025-02-04 15:45:04 -03:00
parent f51e7c83c6
commit 7b588edda6
11 changed files with 903 additions and 943 deletions

View File

@@ -0,0 +1,36 @@
name: Build
on:
push:
branches:
- main
jobs:
quality:
name: Code quality
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.12.6'
- name: Install uv
run: pip install uv
- name: Install dependencies
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
run: uv sync --dev
- name: lint
run: make lint
- uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
# Send Slack notification on failure
- name: Notify Slack on failure
if: failure()
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":"*Erro na execução do workflow*\n\nOcorreu um erro durante a execução do workflow do GitHub Actions.\n\n*Detalhes do erro:*\n- Nome do job: ${{ github.job }}\n- Nome do workflow: ${{ github.workflow }}\n- Repositório: ${{ github.repository }}\n- Branch: ${{ github.ref }}\n- Commit: ${{ github.sha }}\n- Autor do commit: ${{ github.actor }}\n\nPor favor, verifique o log do workflow para mais detalhes."}' https://hooks.slack.com/services/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

View File

@@ -0,0 +1,73 @@
name: Creates a docker image for production
on:
push:
tags:
- 'v*'
jobs:
build:
name: Build the docker image
runs-on: ubuntu-latest
steps:
- name: Build started
uses: voxmedia/github-action-slack-notify-build@v1
if: success()
with:
channel: ci-notifications
status: STARTED
color: good
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: redbeard/mines-backend
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
env:
SCOPE: production
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build finished
if: success()
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel: ci-notifications
status: SUCCESS
color: good
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
deploy:
name: Deploy
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Deploy to production
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
script: |
cd /media/data/apps/mines-backend
docker pull redbeard/mines-backend:latest
docker-compose up -d app0
docker-compose up -d app1
docker exec -t mines-be0 python manage.py migrate
docker image prune -f