Fix Forgejo workflow: improve git push handling and add artifact uploads
Some checks failed
Compile apt-layer / compile (push) Failing after 0s
Some checks failed
Compile apt-layer / compile (push) Failing after 0s
This commit is contained in:
parent
dfab658040
commit
b067da4d82
1 changed files with 33 additions and 3 deletions
|
|
@ -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 }}
|
||||
|
||||
# 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue