1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-03-08 13:19:05 +00:00
ProxmoxVE/.github/workflows/generate-app-headers.yaml
2025-01-10 13:02:36 +01:00

76 lines
2.6 KiB
YAML

name: Update .app-headers in /misc
on:
push:
branches: ["main"]
workflow_dispatch:
jobs:
update-and-create-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure we have full access to all branches
# Step 2: Check if update-app-headers branch exists, create if not
- name: Check or Create update-app-headers branch
run: |
git fetch origin
if ! git show-ref --quiet refs/heads/update-app-headers; then
echo "Creating 'update-app-headers' branch."
git checkout -b update-app-headers origin/main
else
echo "Switching to 'update-app-headers' branch."
git checkout update-app-headers
fi
# Step 3: Ensure .app-headers file exists (if missing, create it)
- name: Ensure .app-headers file exists
run: |
if [ ! -f ".app-headers" ]; then
echo "The .app-headers file does not exist. Creating it."
echo "Generated by CI" > .app-headers
else
echo ".app-headers already exists."
fi
# Step 4: Compare .app-headers with main, commit if changes
- name: Compare with main and commit changes
run: |
git fetch origin
DIFF=$(git diff --quiet origin/main..origin/update-app-headers -- .app-headers || echo "Changes detected")
if [[ "$DIFF" == "Changes detected" ]]; then
echo "Changes detected in .app-headers. Committing changes."
git commit -am "[core]: update .app-headers to latest version"
git push origin update-app-headers --force
else
echo "No changes in .app-headers. Skipping commit."
fi
# Step 5: Create Pull Request if changes detected
- name: Create Pull Request if changes detected
run: |
PR_EXISTS=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
if [ -z "$PR_EXISTS" ]; then
echo "Creating a new PR."
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
else
echo "PR already exists."
fi
# Step 6: Final status output
- name: Output final status
run: |
echo "Workflow completed successfully. Branch and PR status updated."