From 75f95c2936f59b0afa7cdbcd583eb8492e6a7e63 Mon Sep 17 00:00:00 2001 From: Ivan Carlos Date: Tue, 9 Dec 2025 04:57:55 +0000 Subject: [PATCH] Add .gitea/workflows/simplesbentocreation.yml --- .gitea/workflows/simplesbentocreation.yml | 79 +++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .gitea/workflows/simplesbentocreation.yml diff --git a/.gitea/workflows/simplesbentocreation.yml b/.gitea/workflows/simplesbentocreation.yml new file mode 100644 index 0000000..57b0cfb --- /dev/null +++ b/.gitea/workflows/simplesbentocreation.yml @@ -0,0 +1,79 @@ +name: Sync Upstream and Build Docker Image +run-name: Build BentoPDF (Simple Mode) based on Upstream + +on: + schedule: + # Roda diariamente às 04:00 AM + - cron: '0 4 * * *' + # Permite rodar manualmente pela interface do Gitea + workflow_dispatch: + +jobs: + check-and-build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Install dependencies + run: | + apt-get update && apt-get install -y curl jq + + - name: Check Upstream Latest Commit + id: check + run: | + # Pega o SHA curto do último commit na branch MAIN do repositório original + UPSTREAM_SHA=$(curl -s https://api.github.com/repos/alam00000/bentopdf/commits/main | jq -r .sha | head -c 7) + echo "Latest upstream SHA: $UPSTREAM_SHA" + echo "sha=$UPSTREAM_SHA" >> $GITHUB_OUTPUT + + - name: Login to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: git.icc.gg + username: ${{ gitea.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Check if Image Already Exists + id: exists + run: | + # Verifica se já temos uma imagem com essa tag no registro local + if docker manifest inspect git.icc.gg/${{ gitea.repository }}:${{ steps.check.outputs.sha }} > /dev/null 2>&1; then + echo "Image for commit ${{ steps.check.outputs.sha }} already exists." + echo "skip=true" >> $GITHUB_OUTPUT + else + echo "New update found (or image missing). Proceeding to build." + echo "skip=false" >> $GITHUB_OUTPUT + fi + + - name: Checkout Upstream Code + if: steps.exists.outputs.skip == 'false' + uses: actions/checkout@v4 + with: + repository: alam00000/bentopdf + ref: main # Usando main conforme solicitado + + - name: Inject SIMPLE_MODE into Dockerfile + if: steps.exists.outputs.skip == 'false' + run: | + # Insere a variável de ambiente no final do Dockerfile + echo "" >> Dockerfile + echo "ENV SIMPLE_MODE=true" >> Dockerfile + echo "Custom ENV injected successfully." + # Mostra as últimas linhas para confirmar + tail -n 5 Dockerfile + + - name: Set up Docker Buildx + if: steps.exists.outputs.skip == 'false' + uses: docker/setup-buildx-action@v3 + + - name: Build and Push Docker Image + if: steps.exists.outputs.skip == 'false' + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + git.icc.gg/${{ gitea.repository }}:latest + git.icc.gg/${{ gitea.repository }}:${{ steps.check.outputs.sha }} \ No newline at end of file