Update workflow: Create Pull Requests instead of direct push
This commit is contained in:
@@ -57,11 +57,36 @@ jobs:
|
||||
git status
|
||||
fi
|
||||
|
||||
- name: Commit and push changes
|
||||
- name: Create branch and commit changes
|
||||
id: create_branch
|
||||
if: steps.check_changes.outputs.changed == 'true'
|
||||
run: |
|
||||
git commit -m "Daily law updates from RSS - $(date +'%Y-%m-%d %H:%M:%S UTC')" || exit 0
|
||||
git push origin main || echo "Push fehlgeschlagen"
|
||||
BRANCH_NAME="update-laws-$(date +'%Y%m%d-%H%M%S')"
|
||||
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
|
||||
git checkout -b $BRANCH_NAME
|
||||
git commit -m "Update laws from RSS - $(date +'%Y-%m-%d %H:%M:%S UTC')" || exit 0
|
||||
git push origin $BRANCH_NAME || echo "Push fehlgeschlagen"
|
||||
|
||||
- name: Create Pull Request
|
||||
if: steps.check_changes.outputs.changed == 'true'
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
BRANCH_NAME="${{ steps.create_branch.outputs.branch_name }}"
|
||||
REPO="${{ github.repository }}"
|
||||
GITEA_INSTANCE="https://git.coded.law"
|
||||
|
||||
# Erstelle Pull Request via Gitea API
|
||||
curl -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"title\": \"Update laws from RSS - $(date +'%Y-%m-%d')\",
|
||||
\"head\": \"$BRANCH_NAME\",
|
||||
\"base\": \"main\",
|
||||
\"body\": \"Automatische Gesetzes-Updates vom RSS-Feed.\\n\\nBitte überprüfe die Änderungen vor dem Merge.\"
|
||||
}" \
|
||||
"$GITEA_INSTANCE/api/v1/repos/$REPO/pulls" || echo "PR-Erstellung fehlgeschlagen"
|
||||
|
||||
- name: Summary
|
||||
if: always()
|
||||
@@ -69,7 +94,8 @@ jobs:
|
||||
echo "## Update-Zusammenfassung"
|
||||
echo "- Workflow ausgeführt: $(date)"
|
||||
if [ "${{ steps.check_changes.outputs.changed }}" == "true" ]; then
|
||||
echo "- ✅ Änderungen wurden committed und gepusht"
|
||||
echo "- ✅ Änderungen wurden in Branch ${{ steps.create_branch.outputs.branch_name }} committed"
|
||||
echo "- ✅ Pull Request wurde erstellt"
|
||||
else
|
||||
echo "- ℹ️ Keine Änderungen gefunden"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user