CI: Fix working with branches with update.sh
authorPablo Zmdl <redacted>
Tue, 3 Dec 2024 17:58:18 +0000 (18:58 +0100)
committerPablo Zmdl <redacted>
Tue, 3 Dec 2024 19:20:42 +0000 (20:20 +0100)
.github/workflows/update-sh.yml

index 62c56e6cda70514b43a23eb82d0e76ae21c5f5a1..be8810db42781e9811cd4001536d219cc992f407 100644 (file)
@@ -3,6 +3,7 @@ name: update.sh
 permissions:
   # Git push permissions are needed
   contents: write
+  pull-requests: write
 
 on:
   push:
@@ -24,13 +25,15 @@ jobs:
       run: ./update.sh
     - name: Commit files
       run: |
+        BRANCH="changes-from-update.sh-$(date +'%Y-%m-%d')"
+        git show-ref --quiet "$BRANCH" && { "ERROR: Branch $BRANCH already exists";  exit 1; }
+        git switch -C "$BRANCH"
         git config --local user.email "workflow@github.com"
         git config --local user.name "GitHub Workflow"
-        git switch -C changes-from-update.sh
         git add -A
         git commit -m "Update roundcube version (via update.sh)" || echo "Nothing to update"
-        git push --set-upstream origin changes-from-update.sh
+        git push --set-upstream origin "$BRANCH"
     - name: Create Pull Request
-      run: gh pr create -B master -H changes-from-update.sh --title 'Changes from update.sh' --assignee pabzm
+      run: gh pr create -B master -H changes-from-update.sh --title 'Changes from update.sh' --body "These are the changes of the automated run of ./update.sh" --assignee pabzm
       env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
git clone https://git.99rst.org/PROJECT