1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-02-01 21:31:52 +00:00

Update and rename App_Header_Merge_Into_main.yaml to auto-update-app-headers.yml

This commit is contained in:
CanbiZ 2025-01-14 14:43:07 +01:00 committed by GitHub
parent 3830527ef2
commit 692f3caab6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 63 additions and 66 deletions

View File

@ -1,66 +0,0 @@
name: Auto Update .app-headers and Create PR
on:
push:
branches:
- main
paths:
- 'ct/**.sh'
jobs:
update-app-headers:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v2
# Step 2: Set up Git user for committing changes
- name: Set up Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
# Step 3: Ensure .app-headers file exists
- name: Ensure .app-headers file exists
run: |
if [ ! -f ct/.app-headers ]; then
echo "Creating .app-headers file."
touch ct/.app-headers
fi
# Step 4: Process the ct/*.sh files and update .app-headers
- name: Update .app-headers with figlet output
run: |
echo "Updating .app-headers with figlet output."
for script in ct/*.sh; do
if grep -q 'APP=' "$script"; then
APP_NAME=$(grep -oP 'APP=\K\w+' "$script")
echo "Processing $script for APP: \"$APP_NAME\""
figlet "$APP_NAME" >> ct/.app-headers
fi
done
# Step 5: Check out and merge main into the update-app-headers branch without committing
- name: Merge main into update-app-headers
run: |
git fetch origin
git checkout update-app-headers
git merge origin/main --no-ff --no-commit -m "Merge main into update-app-headers"
echo "Merge complete. Please review and commit the changes manually."
# Step 6: Check if a PR exists and create one if it doesn't
- name: Create Pull Request if not exists
run: |
PR_EXISTS=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
if [ -z "$PR_EXISTS" ]; then
echo "Creating a new PR."
PR_URL=$(gh pr create --title "[core]: update .app-headers to latest version" \
--body "This PR automatically updates the .app-headers file." \
--head update-app-headers \
--base main)
echo "PR created: $PR_URL"
else
echo "PR already exists."
fi

View File

@ -0,0 +1,63 @@
name: Auto Update .app-headers with Hard Merge from Main
on:
push:
branches:
- main
paths:
- 'ct/**.sh'
jobs:
auto-update:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v2
# Step 2: Set up Git user
- name: Set up Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
# Step 3: Reset update-app-headers to main
- name: Reset update-app-headers branch to main
run: |
git checkout -B update-app-headers origin/main
echo "Branch update-app-headers reset to match main"
# Step 4: Ensure .app-headers file exists
- name: Ensure .app-headers file exists
run: |
touch ct/.app-headers
# Step 5: Update .app-headers with figlet output
- name: Update .app-headers
run: |
output_file="./ct/.app-headers"
> "$output_file" # Clear or create the file
current_date=$(date +"%m-%d-%Y")
echo "### Generated on $current_date" >> "$output_file"
echo "##################################################" >> "$output_file"
echo >> "$output_file"
find ./ct -type f -name "*.sh" | sort | while read -r script; do
app_name=$(grep -oP '^APP="\K[^"]+' "$script" 2>/dev/null)
if [[ -n "$app_name" ]]; then
figlet_output=$(figlet -f slant "$app_name" 2>/dev/null || echo "FIGLET ERROR: $app_name")
echo "### $(basename "$script")" >> "$output_file"
echo "APP=$app_name" >> "$output_file"
echo "$figlet_output" >> "$output_file"
echo >> "$output_file"
fi
done
# Step 6: Commit and push changes
- name: Commit and push changes
run: |
git add ct/.app-headers
git commit -m "Update .app-headers on $(date +"%Y-%m-%d")" || echo "No changes to commit"
git push --force origin update-app-headers