Add .gitea/workflows/simplesbentocreation.yml
This commit is contained in:
79
.gitea/workflows/simplesbentocreation.yml
Normal file
79
.gitea/workflows/simplesbentocreation.yml
Normal file
@@ -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 }}
|
||||
Reference in New Issue
Block a user