79 lines
2.6 KiB
YAML
79 lines
2.6 KiB
YAML
name: Sync Upstream and Build Docker Image
|
|
run-name: Build BentoPDF (Simple Mode) based on Upstream
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 4 * * *'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
check-and-build:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: catthehacker/ubuntu:act-latest
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Install dependencies
|
|
run: |
|
|
apt-get update && apt-get install -y curl jq git
|
|
|
|
- name: Check Upstream Latest Commit
|
|
id: check
|
|
run: |
|
|
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.CR_PAT }}
|
|
|
|
- name: Check if Image Already Exists
|
|
id: exists
|
|
run: |
|
|
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
|
|
|
|
# --- MUDANÇA AQUI: Usamos git clone manual para evitar erro de credencial ---
|
|
- name: Clone Upstream Code Manually
|
|
if: steps.exists.outputs.skip == 'false'
|
|
run: |
|
|
# Limpa o diretório atual caso tenha lixo
|
|
rm -rf * .git
|
|
# Clona o repo público do GitHub sem tentar usar tokens do Gitea
|
|
git clone --depth 1 --branch main https://github.com/alam00000/bentopdf.git .
|
|
ls -la # Lista para confirmar que baixou
|
|
|
|
- name: Inject SIMPLE_MODE into Dockerfile
|
|
if: steps.exists.outputs.skip == 'false'
|
|
run: |
|
|
echo "" >> Dockerfile
|
|
echo "ENV SIMPLE_MODE=true" >> Dockerfile
|
|
echo "Custom ENV injected successfully."
|
|
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 }} |