From b067da4d820e442d23a325f31438f798458b33d0 Mon Sep 17 00:00:00 2001 From: robojerk Date: Tue, 15 Jul 2025 08:46:24 -0700 Subject: [PATCH] Fix Forgejo workflow: improve git push handling and add artifact uploads --- .forgejo/workflows/compile-apt-layer.yml | 36 ++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/compile-apt-layer.yml b/.forgejo/workflows/compile-apt-layer.yml index 606c075..0ca7f2f 100644 --- a/.forgejo/workflows/compile-apt-layer.yml +++ b/.forgejo/workflows/compile-apt-layer.yml @@ -246,13 +246,43 @@ jobs: echo "Files are available in the artifacts/ directory" echo "==========================================" + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: apt-layer-compiled-scripts + path: | + artifacts/apt-layer.sh + artifacts/install-apt-layer.sh + artifacts/COMPILATION_REPORT.md + retention-days: 30 + - name: Commit compiled scripts (if on main/master) if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' run: | echo "Committing compiled scripts to repository..." + + # Configure git git config --local user.email "action@github.com" git config --local user.name "GitHub Action" + + # Add the compiled files git add apt-layer.sh install-apt-layer.sh - git diff --staged --quiet || git commit -m "Auto-compile apt-layer and installer from commit ${{ github.sha }}" - # Push to the current branch (handle detached HEAD) - git push origin HEAD:${{ github.ref_name }} \ No newline at end of file + + # Check if there are changes to commit + if git diff --staged --quiet; then + echo "No changes to commit - compiled files are identical to repository" + else + # Commit the changes (this works even in detached HEAD) + git commit -m "Auto-compile apt-layer and installer from commit ${{ github.sha }}" + + # Push directly to the target branch using the commit hash + echo "Pushing compiled scripts to ${{ github.ref_name }}..." + if git push origin HEAD:${{ github.ref_name }}; then + echo "✅ Compiled scripts successfully pushed to ${{ github.ref_name }}" + else + echo "⚠️ Failed to push to repository, but compilation was successful" + echo "📦 Compiled scripts are available as workflow artifacts" + echo "📝 You can manually download and commit the compiled scripts" + exit 0 # Don't fail the workflow, compilation was successful + fi + fi \ No newline at end of file