ci: daily upstream merge with PR/issue, tag-based image publishing
- scripts/upstream-sync.sh + upstream-sync-check.yml: fast-forward upstream-sync, merge upstream into maintenance/sync-upstream-<sha> from maintained-develop, build/vet/test, open PR (or Issue on conflict), warn on newer whatsmeow. Optional AUTO_MERGE_UPSTREAM repo variable; maintained-stable never touched. - docker-build.yml: publish git.jf.eng.br/jfeng/evogo:<version> and <version>-<sha7> on tag v*, startup smoke test, non-blocking Trivy scan, :latest only on explicit promote_latest. - CHANGELOG and maintenance docs updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
e02441fc4e
commit
0379082181
6 files changed
+417
-63
No files matched your search
@@ -1,11 +1,19 @@
|
||||
name: Docker - Build e Publicacao
|
||||
|
||||
# Publicacao no registry do Gitea (git.jf.eng.br/jfeng/evogo):
|
||||
# - push de tag v<versao> (ex: v0.7.2-evogo.1) = release aprovado -> publica
|
||||
# git.jf.eng.br/jfeng/evogo:<versao> (tag semantica)
|
||||
# git.jf.eng.br/jfeng/evogo:<versao>-<sha7> (tag imutavel do commit)
|
||||
# - workflow_dispatch com publish_image=true -> idem, versao = target_tag ou VERSION
|
||||
# - push em maintained-stable -> apenas build + teste + scan (nao publica)
|
||||
# :latest so e atualizada com promote_latest=true (manual), nunca automaticamente.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- maintained-stable
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
publish_image:
|
||||
@@ -14,14 +22,23 @@ on:
|
||||
default: false
|
||||
required: true
|
||||
target_tag:
|
||||
description: 'Tag semantica para publicacao (ex: 0.7.2)'
|
||||
description: 'Tag semantica para publicacao (ex: 0.7.2-evogo.1). Vazio = arquivo VERSION'
|
||||
type: string
|
||||
default: ''
|
||||
required: false
|
||||
promote_latest:
|
||||
description: 'Tambem atualizar :latest (somente versoes aprovadas em maintained-stable)'
|
||||
type: boolean
|
||||
default: false
|
||||
required: false
|
||||
|
||||
env:
|
||||
REGISTRY: git.jf.eng.br
|
||||
IMAGE: git.jf.eng.br/jfeng/evogo
|
||||
|
||||
jobs:
|
||||
build_docker:
|
||||
name: Build e Verificacao Docker
|
||||
name: Build, Scan e Publicacao
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
@@ -31,44 +48,72 @@ jobs:
|
||||
- name: Obter Versao e Commit SHA
|
||||
id: meta
|
||||
run: |
|
||||
VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0")
|
||||
COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
echo "commit_sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT
|
||||
echo "image_tag=${VERSION}-${COMMIT_SHA}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Configurar Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
if [ "${{ github.ref_type }}" = "tag" ]; then
|
||||
VERSION="${{ github.ref_name }}"
|
||||
VERSION="${VERSION#v}"
|
||||
PUBLISH=true
|
||||
else
|
||||
VERSION="${{ github.event.inputs.target_tag }}"
|
||||
[ -n "$VERSION" ] || VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0")
|
||||
PUBLISH="${{ github.event.inputs.publish_image == 'true' }}"
|
||||
fi
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
echo "commit_sha=${COMMIT_SHA}" >> "$GITHUB_OUTPUT"
|
||||
echo "image_tag=${VERSION}-${COMMIT_SHA}" >> "$GITHUB_OUTPUT"
|
||||
echo "publish=${PUBLISH}" >> "$GITHUB_OUTPUT"
|
||||
echo "Versao: ${VERSION} | Commit: ${COMMIT_SHA} | Publicar: ${PUBLISH}"
|
||||
|
||||
- name: Construir Imagem Docker Local
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
load: true
|
||||
tags: evogo:local
|
||||
build-args: |
|
||||
VERSION=${{ steps.meta.outputs.image_tag }}
|
||||
|
||||
- name: Testar Execucao Basica do Container
|
||||
run: |
|
||||
docker run --rm evogo:local --help || echo "Container executou verificacao inicial com sucesso"
|
||||
docker build \
|
||||
--build-arg VERSION=${{ steps.meta.outputs.image_tag }} \
|
||||
-t evogo:ci-${{ steps.meta.outputs.commit_sha }} .
|
||||
|
||||
- name: Login no Gitea Package Registry (se aprovado)
|
||||
if: ${{ github.event.inputs.publish_image == 'true' || github.event.inputs.publish_image == true }}
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.jf.eng.br
|
||||
username: ${{ secrets.REGISTRY_USER || github.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN || secrets.GITEA_TOKEN }}
|
||||
- name: Testar Inicializacao do Container
|
||||
run: |
|
||||
# O binario precisa subir e falhar apenas por falta de banco/config,
|
||||
# nunca por erro de link (CGO/libwebp/libjpeg) ou arquivo ausente.
|
||||
set +e
|
||||
timeout 20 docker run --rm evogo:ci-${{ steps.meta.outputs.commit_sha }} > /tmp/run.log 2>&1
|
||||
set -e
|
||||
tail -20 /tmp/run.log
|
||||
if grep -qiE "error while loading shared libraries|exec format error|exec /app/server" /tmp/run.log; then
|
||||
echo "Falha ao iniciar o binario dentro da imagem"; exit 1
|
||||
fi
|
||||
docker run --rm --entrypoint sh evogo:ci-${{ steps.meta.outputs.commit_sha }} -c 'test -x /app/server && test -d /app/manager/dist && cat /app/VERSION'
|
||||
|
||||
- name: Publicar Imagens no Registry (apenas com aprovacao expressa)
|
||||
if: ${{ github.event.inputs.publish_image == 'true' || github.event.inputs.publish_image == true }}
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
git.jf.eng.br/jfeng/evogo:${{ steps.meta.outputs.image_tag }}
|
||||
git.jf.eng.br/jfeng/evogo:${{ steps.meta.outputs.version }}
|
||||
build-args: |
|
||||
VERSION=${{ steps.meta.outputs.image_tag }}
|
||||
- name: Verificar Vulnerabilidades (Trivy, nao bloqueante)
|
||||
continue-on-error: true
|
||||
run: |
|
||||
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aquasec/trivy:latest \
|
||||
image --severity HIGH,CRITICAL --ignore-unfixed --no-progress \
|
||||
evogo:ci-${{ steps.meta.outputs.commit_sha }}
|
||||
|
||||
- name: Login no Gitea Package Registry
|
||||
if: steps.meta.outputs.publish == 'true'
|
||||
run: |
|
||||
USER="${{ secrets.REGISTRY_USER }}"
|
||||
[ -n "$USER" ] || USER="${{ github.actor }}"
|
||||
TOKEN="${{ secrets.REGISTRY_TOKEN }}"
|
||||
[ -n "$TOKEN" ] || TOKEN="${{ secrets.GITEA_TOKEN }}"
|
||||
echo "$TOKEN" | docker login "$REGISTRY" -u "$USER" --password-stdin
|
||||
|
||||
- name: Publicar Imagens no Registry
|
||||
if: steps.meta.outputs.publish == 'true'
|
||||
run: |
|
||||
SRC=evogo:ci-${{ steps.meta.outputs.commit_sha }}
|
||||
for TAG in "${{ steps.meta.outputs.image_tag }}" "${{ steps.meta.outputs.version }}"; do
|
||||
docker tag "$SRC" "$IMAGE:$TAG"
|
||||
docker push "$IMAGE:$TAG"
|
||||
echo "Publicado: $IMAGE:$TAG"
|
||||
done
|
||||
if [ "${{ github.event.inputs.promote_latest }}" = "true" ]; then
|
||||
docker tag "$SRC" "$IMAGE:latest"
|
||||
docker push "$IMAGE:latest"
|
||||
echo "Publicado: $IMAGE:latest"
|
||||
fi
|
||||
|
||||
- name: Limpeza
|
||||
if: always()
|
||||
run: docker image rm -f evogo:ci-${{ steps.meta.outputs.commit_sha }} >/dev/null 2>&1 || true
|
||||
Reference in new issue
Block a user