Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: build-image

on:
push:
branches: [main]

permissions:
contents: read
pull-requests: read
packages: write

jobs:
publicar:
runs-on: ubuntu-latest

steps:
- name: baixar código
uses: actions/checkout@v4

- name: preparar docker builds
uses: docker/setup-buildx-action@v3

- name: entrar no GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: construir e publicar imagem
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/appacta/acta-auth-api:sha-${{ github.sha }}
labels: |
org.opencontainers.image.source=https://github.com/AppActa/acta-auth-api
org.opencontainers.image.revision=${{ github.sha }}
- name: baixar manifests do plataform
uses: actions/checkout@v4
with:
repository: AppActa/acta-platform
ref: main
token: ${{ secrets.ACTA_PLATFORM_TOKEN }}

- name: atualizar imagem no plataform
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }}
PUSHED_AT: ${{ github.event.head_commit.timestamp }}
run: |
pull_request=$(gh api "repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls" --jq '.[0].html_url' 2>/dev/null || true)
pull_request=${pull_request:-"não identificada"}
commit_author="${COMMIT_AUTHOR}"
commit_author=${commit_author:-"não identificado"}
pushed_at="${PUSHED_AT}"
pushed_at=${pushed_at:-"não informado"}

sed -i "s#^\([[:space:]]*image: ghcr.io/appacta/acta-auth-api\).*#\1:sha-${GITHUB_SHA}#" apps/auth-api.yaml
git diff --quiet -- apps/auth-api.yaml && exit 0
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add apps/auth-api.yaml
git commit -m "chore: atualizar imagem de acta-auth-api" -m "PR: ${pull_request}
SHA: ${GITHUB_SHA}
Autor do commit: ${commit_author}
Usuário do push: ${GITHUB_ACTOR}
Data do push: ${pushed_at}"
git push origin main
80 changes: 80 additions & 0 deletions .github/workflows/validacao.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: validacao

on:
pull_request:
branches: [main]
push:
branches: [main]

permissions:
contents: read
security-events: write

jobs:
build:
runs-on: ubuntu-latest

# postgres temporário exclusivo da execução
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: acta_test
POSTGRES_USER: acta_test
POSTGRES_PASSWORD: acta_test
options: >-
--health-cmd "pg_isready -U acta_test -d acta_test"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
# baixa o código do pull request
- uses: actions/checkout@v4

- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '17'
cache: maven

# executa o script sql no banco de testes
- name: criar banco de testes
env:
PGPASSWORD: acta_test
run: psql -h localhost -U acta_test -d acta_test -f src/main/resources/sql/script.sql

# compila e executa os testes com o profile test
- run: >-
bash ./mvnw -B -Daether.transport.http.retryHandler.count=5
-Daether.transport.http.retryHandler.serviceUnavailable=429,502,503
clean verify

# procura vulnerabilidades no código java
seguranca:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

# prepara o codeql para analisar java
- uses: github/codeql-action/init@v4
with:
languages: java
build-mode: manual

- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '17'

# compila para disponibilizar as classes ao codeql
- run: >-
bash ./mvnw -B -Daether.transport.http.retryHandler.count=5
-Daether.transport.http.retryHandler.serviceUnavailable=429,502,503
clean package -DskipTests

# publica os alertas na aba security do github
- uses: github/codeql-action/analyze@v4
Loading
Loading