mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-04 06:50:15 +00:00
Merge remote-tracking branch 'origin/main' into update-app-headers
This commit is contained in:
commit
8d3551ac22
106
.github/workflows/generate-app-headers.yaml
vendored
106
.github/workflows/generate-app-headers.yaml
vendored
@ -1,14 +1,11 @@
|
|||||||
name: Update .app-headers in /misc
|
name: Update .app-headers in /misc
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
push:
|
||||||
types:
|
paths:
|
||||||
- closed
|
- 'ct/*' # Action wird ausgelöst, wenn sich etwas in ct/ ändert
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
if: github.event.pull_request.merged == true
|
|
||||||
schedule:
|
|
||||||
- cron: "59 23 * * *" # Führen den Workflow täglich um 23:59 UTC aus
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@ -23,97 +20,72 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Fetch all branches for full context
|
fetch-depth: 0 # Ensure we have full access to all branches
|
||||||
|
|
||||||
# Step 2: Set up Git user
|
# Step 2: Configure git user
|
||||||
- name: Configure Git user
|
- name: Configure Git user
|
||||||
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: Check or create update-app-headers branch
|
# Step 3: Merge main into update-app-headers
|
||||||
- name: Check or create update-app-headers branch
|
|
||||||
run: |
|
|
||||||
git fetch origin
|
|
||||||
if git show-ref --quiet refs/heads/update-app-headers; then
|
|
||||||
echo "Switching to 'update-app-headers' branch."
|
|
||||||
git checkout update-app-headers
|
|
||||||
else
|
|
||||||
echo "Creating 'update-app-headers' branch."
|
|
||||||
git checkout -b update-app-headers origin/main
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Step 4: Merge main into update-app-headers
|
|
||||||
- name: Merge main into update-app-headers
|
- name: Merge main into update-app-headers
|
||||||
run: |
|
run: |
|
||||||
git merge origin/main --no-edit || echo "No changes to merge from main."
|
git fetch origin
|
||||||
|
git checkout update-app-headers || git checkout -b update-app-headers
|
||||||
# Step 5: Check all .sh files in ct/ directory that contain APP=
|
git merge origin/main --no-ff --no-edit
|
||||||
- name: Check .sh files in ct/ that contain APP=
|
|
||||||
run: |
|
|
||||||
echo "Checking .sh files in ct/ directory that contain APP=."
|
|
||||||
SH_FILES=$(find ct/ -type f -name "*.sh" -exec grep -l "APP=" {} \;)
|
|
||||||
|
|
||||||
if [ -z "$SH_FILES" ]; then
|
|
||||||
echo "No .sh files with APP= found in ct/ directory."
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "Found .sh files with APP= in ct/ directory:"
|
|
||||||
echo "$SH_FILES"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Step 6: Overwrite .app-headers
|
|
||||||
- name: Overwrite .app-headers file
|
|
||||||
run: |
|
|
||||||
# Ensure .app-headers file exists
|
|
||||||
if [ ! -f ".app-headers" ]; then
|
|
||||||
echo "Creating .app-headers file."
|
|
||||||
echo "Generated by CI on $(date)" > .app-headers
|
|
||||||
else
|
|
||||||
echo ".app-headers file already exists."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Overwrite .app-headers with figlet output of each .sh file name containing APP=
|
|
||||||
echo "Overwriting .app-headers with new entries."
|
|
||||||
> .app-headers # Clear the existing file
|
|
||||||
for FILE in $SH_FILES; do
|
|
||||||
APP_NAME=$(basename "$FILE" .sh)
|
|
||||||
echo "$(figlet $APP_NAME)" >> .app-headers
|
|
||||||
done
|
|
||||||
|
|
||||||
# Step 7: Commit and push changes (if any)
|
|
||||||
- name: Commit and push changes
|
|
||||||
run: |
|
|
||||||
git diff --quiet -- .app-headers || git commit -am "[core]: update .app-headers to latest version"
|
|
||||||
git push origin update-app-headers --force
|
git push origin update-app-headers --force
|
||||||
|
|
||||||
# Step 8: Create Pull Request if changes detected
|
# Step 4: 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
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Step 5: Loop through ct/ scripts and execute figlet if APP= is found
|
||||||
|
- name: Update .app-headers with figlet output
|
||||||
|
run: |
|
||||||
|
echo "Updating .app-headers with figlet output."
|
||||||
|
for file in ct/*.sh; do
|
||||||
|
if grep -q "APP=" "$file"; then
|
||||||
|
APP_NAME=$(grep -oP 'APP=\K.*' "$file")
|
||||||
|
echo "Processing $file for APP: $APP_NAME"
|
||||||
|
figlet "$APP_NAME" >> ct/.app-headers
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Step 6: Commit the changes to .app-headers
|
||||||
|
- name: Commit updated .app-headers
|
||||||
|
run: |
|
||||||
|
git diff --quiet -- ct/.app-headers || git commit -am "[core]: update .app-headers to latest version"
|
||||||
|
git push origin update-app-headers --force
|
||||||
|
|
||||||
|
# Step 7: Create Pull Request to merge changes into main
|
||||||
- name: Create Pull Request if changes detected
|
- name: Create Pull Request if changes detected
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
echo "Checking if PR exists."
|
|
||||||
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')
|
||||||
echo "PR_EXISTS: $PR_EXISTS"
|
|
||||||
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" \
|
||||||
--body "This PR automatically updates the .app-headers file." \
|
--body "This PR automatically updates the .app-headers file." \
|
||||||
--head update-app-headers \
|
--head update-app-headers \
|
||||||
--base main)
|
--base main --no-edit -q .url)
|
||||||
echo "PR created: $PR_URL"
|
echo "PR created: $PR_URL"
|
||||||
else
|
else
|
||||||
echo "PR already exists."
|
echo "PR already exists."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 9: Automatically merge PR
|
# Step 8: Automatically merge PR
|
||||||
- name: Automatically merge PR
|
- name: Automatically merge PR
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
echo "Attempting to merge PR."
|
echo "Attempting to merge PR."
|
||||||
PR_NUMBER=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
|
PR_NUMBER=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
|
||||||
echo "Found PR number: $PR_NUMBER"
|
|
||||||
if [ -n "$PR_NUMBER" ]; then
|
if [ -n "$PR_NUMBER" ]; then
|
||||||
gh pr merge "$PR_NUMBER" --merge --admin --delete-branch
|
gh pr merge "$PR_NUMBER" --merge --admin --delete-branch
|
||||||
echo "PR merged successfully."
|
echo "PR merged successfully."
|
||||||
@ -121,7 +93,7 @@ jobs:
|
|||||||
echo "No PR found to merge."
|
echo "No PR found to merge."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 10: Final status output
|
# Step 9: Final status output
|
||||||
- name: Output final status
|
- name: Output final status
|
||||||
run: |
|
run: |
|
||||||
echo "Workflow completed successfully. Branch and PR status updated."
|
echo "Workflow completed successfully. Branch and PR status updated."
|
||||||
|
Loading…
Reference in New Issue
Block a user