Fix Forgejo workflow: improve git push handling and add artifact uploads
Some checks failed
Compile apt-layer / compile (push) Failing after 0s

This commit is contained in:
robojerk 2025-07-15 08:46:24 -07:00
parent dfab658040
commit b067da4d82

View file

@ -246,13 +246,43 @@ jobs:
echo "Files are available in the artifacts/ directory" echo "Files are available in the artifacts/ directory"
echo "==========================================" 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) - name: Commit compiled scripts (if on main/master)
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
run: | run: |
echo "Committing compiled scripts to repository..." echo "Committing compiled scripts to repository..."
# Configure git
git config --local user.email "action@github.com" git config --local user.email "action@github.com"
git config --local user.name "GitHub Action" git config --local user.name "GitHub Action"
# Add the compiled files
git add apt-layer.sh install-apt-layer.sh 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) # Check if there are changes to commit
git push origin HEAD:${{ github.ref_name }} 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