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

Update generate-app-headers.yaml

This commit is contained in:
CanbiZ 2025-01-10 14:52:32 +01:00 committed by GitHub
parent aacb6ca2c9
commit 0c0225a052
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,79 +1,59 @@
name: Update .app-headers in /misc name: Auto Update .app-headers and Create PR
on: on:
push: push:
paths:
- 'ct/*'
branches: branches:
- main - main
workflow_dispatch: paths:
- 'ct/**.sh'
jobs: jobs:
update-and-create-pr: update-app-headers:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps: steps:
# Step 1: Checkout repository # Step 1: Checkout the repository
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v2
with:
fetch-depth: 0 # Ensure we have full access to all branches
# Step 2: Configure git user # Step 2: Set up Git user for committing changes
- name: Configure Git user - name: Set up Git
run: | run: |
git config --global user.name "GitHub Actions" git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com" git config --global user.email "actions@github.com"
# Step 3: Install figlet # Step 3: Ensure .app-headers file exists
- name: Install figlet - name: Ensure .app-headers file exists
run: | run: |
sudo apt-get update if [ ! -f ct/.app-headers ]; then
sudo apt-get install -y figlet echo "Creating .app-headers file."
# Step 4: Merge main into update-app-headers
- name: Merge main into update-app-headers
run: |
git fetch origin
git checkout update-app-headers || git checkout -b update-app-headers
git merge origin/main --no-ff --no-edit
git push origin update-app-headers --force
# Step 5: Ensure .app-headers file exists and initialize it
- name: Initialize .app-headers file
run: |
if [ ! -f "ct/.app-headers" ]; then
echo "Creating .app-headers file"
touch ct/.app-headers touch ct/.app-headers
fi fi
# Step 6: Loop through ct/ scripts and execute figlet if APP= is found # Step 4: Process the ct/*.sh files and update .app-headers
- name: Update .app-headers with figlet output - name: Update .app-headers with figlet output
run: | run: |
echo "Updating .app-headers with figlet output." echo "Updating .app-headers with figlet output."
for file in ct/*.sh; do for script in ct/*.sh; do
if grep -q "APP=" "$file"; then if grep -q 'APP=' "$script"; then
APP_NAME=$(grep -oP 'APP=\K.*' "$file") APP_NAME=$(grep -oP 'APP=\K\w+' "$script")
echo "Processing $file for APP: $APP_NAME" echo "Processing $script for APP: \"$APP_NAME\""
figlet "$APP_NAME" >> ct/.app-headers figlet "$APP_NAME" >> ct/.app-headers
fi fi
done done
# Step 7: Commit the changes to .app-headers # Step 5: Check out and merge main into the update-app-headers branch without committing
- name: Commit updated .app-headers - name: Merge main into update-app-headers
run: | run: |
git diff --quiet -- ct/.app-headers || git commit -am "[core]: update .app-headers to latest version" git fetch origin
git push origin update-app-headers --force 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 8: Create Pull Request to merge changes into main # Step 6: Check if a PR exists and create one if it doesn't
- name: Create Pull Request if changes detected - name: Create Pull Request if not exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
PR_EXISTS=$(gh pr list --head "update-app-headers" --json number --jq '.[].number') PR_EXISTS=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
if [ -z "$PR_EXISTS" ]; then if [ -z "$PR_EXISTS" ]; then
echo "Creating a new PR." echo "Creating a new PR."
PR_URL=$(gh pr create --title "[core]: update .app-headers to latest version" \ PR_URL=$(gh pr create --title "[core]: update .app-headers to latest version" \
@ -84,22 +64,3 @@ jobs:
else else
echo "PR already exists." echo "PR already exists."
fi fi
# Step 9: Automatically merge PR
- name: Automatically merge PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Attempting to merge PR."
PR_NUMBER=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
if [ -n "$PR_NUMBER" ]; then
gh pr merge "$PR_NUMBER" --merge --admin --delete-branch
echo "PR merged successfully."
else
echo "No PR found to merge."
fi
# Step 10: Final status output
- name: Output final status
run: |
echo "Workflow completed successfully. Branch and PR status updated."