ProxmoxVE/.github/workflows/App_Header_Merge_Into_main.yaml

67 lines
2.3 KiB
YAML
Raw Normal View History

2025-01-10 13:52:32 +00:00
name: Auto Update .app-headers and Create PR
on:
2025-01-10 13:28:50 +00:00
push:
2025-01-10 12:44:13 +00:00
branches:
- main
2025-01-10 13:52:32 +00:00
paths:
- 'ct/**.sh'
jobs:
2025-01-10 13:52:32 +00:00
update-app-headers:
runs-on: ubuntu-latest
steps:
2025-01-10 13:52:32 +00:00
# Step 1: Checkout the repository
- name: Checkout repository
2025-01-10 13:52:32 +00:00
uses: actions/checkout@v2
2025-01-10 13:52:32 +00:00
# Step 2: Set up Git user for committing changes
- name: Set up Git
2025-01-10 13:30:04 +00:00
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
2025-01-10 13:52:32 +00:00
# Step 3: Ensure .app-headers file exists
- name: Ensure .app-headers file exists
2025-01-10 12:42:55 +00:00
run: |
2025-01-10 13:52:32 +00:00
if [ ! -f ct/.app-headers ]; then
echo "Creating .app-headers file."
2025-01-10 13:28:50 +00:00
touch ct/.app-headers
2025-01-10 13:15:22 +00:00
fi
2025-01-10 13:52:32 +00:00
# Step 4: Process the ct/*.sh files and update .app-headers
2025-01-10 13:28:50 +00:00
- name: Update .app-headers with figlet output
2025-01-10 13:15:22 +00:00
run: |
2025-01-10 13:28:50 +00:00
echo "Updating .app-headers with figlet output."
2025-01-10 13:52:32 +00:00
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\""
2025-01-10 13:28:50 +00:00
figlet "$APP_NAME" >> ct/.app-headers
fi
2025-01-10 13:15:22 +00:00
done
2025-01-10 13:52:32 +00:00
# Step 5: Check out and merge main into the update-app-headers branch without committing
- name: Merge main into update-app-headers
2025-01-10 12:06:06 +00:00
run: |
2025-01-10 13:52:32 +00:00
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."
2025-01-10 12:00:27 +00:00
2025-01-10 13:52:32 +00:00
# Step 6: Check if a PR exists and create one if it doesn't
- name: Create Pull Request if not exists
2025-01-10 11:04:38 +00:00
run: |
2025-01-10 12:45:36 +00:00
PR_EXISTS=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
2025-01-10 13:52:32 +00:00
2025-01-10 11:04:38 +00:00
if [ -z "$PR_EXISTS" ]; then
2025-01-10 11:49:58 +00:00
echo "Creating a new PR."
2025-01-10 12:45:36 +00:00
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 \
2025-01-10 13:36:06 +00:00
--base main)
2025-01-10 12:45:36 +00:00
echo "PR created: $PR_URL"
2025-01-10 11:21:27 +00:00
else
2025-01-10 11:49:58 +00:00
echo "PR already exists."
2025-01-10 11:04:38 +00:00
fi