1- name : Auto Update .app-headers with Hard Merge from Main
1+ name : Auto Update .app-headers
22
33on :
44 push :
55 branches :
66 - main
77 paths :
88 - ' ct/**.sh'
9- workflow_dispatch :
9+ workflow_dispatch : # Ermöglicht das manuelle Ausführen der Action
1010
1111jobs :
1212 update-app-headers :
1313 runs-on : ubuntu-latest
1414
15+ permissions :
16+ contents : write
17+ pull-requests : write
18+
1519 steps :
16- # Step 1: Checkout the repository
20+ # Step 1: Checkout repository
1721 - name : Checkout repository
1822 uses : actions/checkout@v2
1923
2327 git config --global user.name "GitHub Actions"
2428 git config --global user.email "[email protected] " 2529
26- # Step 3: Install figlet
30+ # Step 3: Install figlet
2731 - name : Install figlet
2832 run : sudo apt-get install -y figlet
2933
@@ -35,20 +39,36 @@ jobs:
3539 env :
3640 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3741
38- # Step 5: Commit the changes directly to main (no temporary branch)
39- - name : Commit changes directly to main
42+ # Step 5: Check if there are any changes
43+ - name : Check if there are any changes
44+ id : verify-diff
45+ run : |
46+ git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT
47+
48+ # Step 6: Commit changes (if any) and create a PR
49+ - name : Commit and create PR if changes exist
50+ if : steps.verify-diff.outputs.changed == 'true'
4051 run : |
52+ git config --global user.name "github-actions[bot]"
53+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
4154 git add ./misc/.app-headers
4255 git commit -m "Update .app-headers file"
43- git push origin main
44-
45- # Step 6: Create Pull Request (PR) to main
46- - name : Create Pull Request to main
47- uses : peter-evans/create-pull-request@v3
48- with :
49- token : ${{ secrets.GITHUB_TOKEN }}
50- base : main
51- head : main # Direkt gegen den main Branch
52- title : " Update .app-headers file"
53- body : " Automated PR to update .app-headers file based on script changes."
54- draft : false # Setze auf true, wenn der PR als Draft erstellt werden soll
56+ # Create a temporary branch for the PR
57+ git checkout -b pr-update-app-headers
58+ git push origin pr-update-app-headers --force
59+
60+ # Create PR against main
61+ gh pr create --title "[Github Action] Update .app-headers file" \
62+ --body "This PR is auto-generated by a Github Action to update the .app-headers file." \
63+ --head pr-update-app-headers \
64+ --base main
65+
66+ - name : Approve pull request
67+ if : steps.verify-diff.outputs.changed == 'true'
68+ env :
69+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
70+ run : |
71+ PR_NUMBER=$(gh pr list --head "pr-update-app-headers" --json number --jq '.[].number')
72+ if [ -n "$PR_NUMBER" ]; then
73+ gh pr review $PR_NUMBER --approve
74+ fi
0 commit comments