[Core] Better Creation of App Headers for next feature (#1719)

* Update Function to crawl app Headers

* Update Function to crawl app Headers
This commit is contained in:
CanbiZ 2025-01-24 14:03:59 +01:00 committed by GitHub
parent a7ee0705e2
commit f29cbe5b46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 39 deletions

View File

@ -1,4 +1,4 @@
name: Auto Update .app-headers name: Auto Update .app-files
on: on:
push: push:
@ -9,7 +9,7 @@ on:
workflow_dispatch: # Ermöglicht das manuelle Ausführen der Action workflow_dispatch: # Ermöglicht das manuelle Ausführen der Action
jobs: jobs:
update-app-headers: update-app-files:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
@ -31,15 +31,15 @@ jobs:
- name: Install figlet - name: Install figlet
run: sudo apt-get install -y figlet run: sudo apt-get install -y figlet
# Step 4: Run the generate-app-headers.sh script to update .app-headers # Step 4: Run the updated generate-app-files.sh script
- name: Run generate-app-headers.sh to update .app-headers - name: Run generate-app-files.sh
run: | run: |
chmod +x .github/workflows/scripts/generate-app-headers.sh chmod +x .github/workflows/scripts/generate-app-headers.sh
.github/workflows/scripts/generate-app-headers.sh .github/workflows/scripts/generate-app-headers.sh
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Step 5: Check if there are any changes # Step 5: Check for changes
- name: Check if there are any changes - name: Check if there are any changes
id: verify-diff id: verify-diff
run: | run: |
@ -51,16 +51,15 @@ jobs:
run: | run: |
git config --global user.name "github-actions[bot]" git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add ./misc/.app-headers git add ct/*.app
git commit -m "Update .app-headers file" git commit -m "Update .app files"
# Create a temporary branch for the PR git checkout -b pr-update-app-files
git checkout -b pr-update-app-headers git push origin pr-update-app-files --force
git push origin pr-update-app-headers --force
# Create PR against main # Create PR against main
gh pr create --title "[core] update .app-headers file" \ gh pr create --title "[core] update .app files" \
--body "This PR is auto-generated by a Github Action to update the .app-headers file." \ --body "This PR is auto-generated by a Github Action to update the .app files." \
--head pr-update-app-headers \ --head pr-update-app-files \
--base main \ --base main \
--label "automated pr" --label "automated pr"
env: env:
@ -71,12 +70,9 @@ jobs:
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
PR_NUMBER=$(gh pr list --head "pr-update-app-headers" --json number --jq '.[].number') PR_NUMBER=$(gh pr list --head "pr-update-app-files" --json number --jq '.[].number')
# Check if the PR was created by the bot (skip review if so)
PR_AUTHOR=$(gh pr view "$PR_NUMBER" --json author --jq '.author.login') PR_AUTHOR=$(gh pr view "$PR_NUMBER" --json author --jq '.author.login')
if [ "$PR_AUTHOR" != "github-actions[bot]" ]; then if [ "$PR_AUTHOR" != "github-actions[bot]" ]; then
gh pr review "$PR_NUMBER" --approve gh pr review "$PR_NUMBER" --approve
else else
echo "PR was created by the bot, skipping review." echo "PR was created by the bot, skipping review."
fi

View File

@ -1,33 +1,28 @@
#!/usr/bin/env bash #!/usr/bin/env bash
output_file="./misc/.app-headers" # Find all .sh files in ./ct directory, sorted alphabetically
> "$output_file" # Clear or create the file
current_date=$(date +"%m-%d-%Y")
# Header with date
{
echo "### Generated on $current_date"
echo "##################################################"
echo
} >> "$output_file"
# Find only regular .sh files in ./ct, sort them alphabetically
find ./ct -type f -name "*.sh" | sort | while read -r script; do find ./ct -type f -name "*.sh" | sort | while read -r script; do
# Extract the APP name from the APP line # Extract the APP name from the APP line
app_name=$(grep -oP '^APP="\K[^"]+' "$script" 2>/dev/null) app_name=$(grep -oP '^APP="\K[^"]+' "$script" 2>/dev/null)
if [[ -n "$app_name" ]]; then if [[ -n "$app_name" ]]; then
# Generate figlet output # Define the output file name based on the .sh file
figlet_output=$(figlet -f slant "$app_name") output_file="${script%.sh}.app"
{
echo "### $(basename "$script")" # Check if the output file already exists
echo "APP=$app_name" if [[ ! -f "$output_file" ]]; then
echo "$figlet_output" # Generate figlet output
echo figlet_output=$(figlet -f slant "$app_name")
} >> "$output_file"
# Write the figlet output to the file
echo "$figlet_output" > "$output_file"
echo "Generated: $output_file"
else
echo "Skipped: $output_file already exists"
fi
else else
echo "No APP name found in $script, skipping." echo "No APP name found in $script, skipping."
fi fi
done done
echo "Generated combined file at $output_file" echo "Completed processing .sh files."