Update auto-update-app-headers.yml

This commit is contained in:
CanbiZ 2025-01-14 15:01:05 +01:00 committed by GitHub
parent 647fb1cb5e
commit 434c938cde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
name: Auto Update .app-headers with Hard Merge from Main
name: Auto Update .app-headers
on:
push:
@ -6,14 +6,18 @@ on:
- main
paths:
- 'ct/**.sh'
workflow_dispatch:
workflow_dispatch: # Ermöglicht das manuelle Ausführen der Action
jobs:
update-app-headers:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
# Step 1: Checkout the repository
# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v2
@ -23,7 +27,7 @@ jobs:
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
# Step 3: Install figlet
# Step 3: Install figlet
- name: Install figlet
run: sudo apt-get install -y figlet
@ -35,20 +39,36 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Step 5: Commit the changes directly to main (no temporary branch)
- name: Commit changes directly to main
# Step 5: Check if there are any changes
- name: Check if there are any changes
id: verify-diff
run: |
git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT
# Step 6: Commit changes (if any) and create a PR
- name: Commit and create PR if changes exist
if: steps.verify-diff.outputs.changed == 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add ./misc/.app-headers
git commit -m "Update .app-headers file"
git push origin main
# Create a temporary branch for the PR
git checkout -b pr-update-app-headers
git push origin pr-update-app-headers --force
# Create PR against main
gh pr create --title "[Github Action] Update .app-headers file" \
--body "This PR is auto-generated by a Github Action to update the .app-headers file." \
--head pr-update-app-headers \
--base main
# Step 6: Create Pull Request (PR) to main
- name: Create Pull Request to main
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: main
head: main # Direkt gegen den main Branch
title: "Update .app-headers file"
body: "Automated PR to update .app-headers file based on script changes."
draft: false # Setze auf true, wenn der PR als Draft erstellt werden soll
- name: Approve pull request
if: steps.verify-diff.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER=$(gh pr list --head "pr-update-app-headers" --json number --jq '.[].number')
if [ -n "$PR_NUMBER" ]; then
gh pr review $PR_NUMBER --approve
fi