mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-01-30 12:30:15 +00:00
67 lines
2.3 KiB
YAML
67 lines
2.3 KiB
YAML
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
|