mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-02-23 21:21:38 +01:00
Update generate-app-headers.yaml
This commit is contained in:
parent
f275cdd62c
commit
7a2f5f55e8
54
.github/workflows/generate-app-headers.yaml
vendored
54
.github/workflows/generate-app-headers.yaml
vendored
@ -17,37 +17,48 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Ensure we have full access to all branches
|
fetch-depth: 0 # Fetch all branches for full context
|
||||||
|
|
||||||
# Step 2: Check or Create update-app-headers branch
|
# Step 2: Set up Git user
|
||||||
- name: Check or Create update-app-headers branch
|
- name: Configure Git user
|
||||||
|
run: |
|
||||||
|
git config --global user.name "GitHub Actions"
|
||||||
|
git config --global user.email "actions@github.com"
|
||||||
|
|
||||||
|
# Step 3: Check or create update-app-headers branch
|
||||||
|
- name: Check or create update-app-headers branch
|
||||||
run: |
|
run: |
|
||||||
git fetch origin
|
git fetch origin
|
||||||
if ! git show-ref --quiet refs/heads/update-app-headers; then
|
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."
|
echo "Switching to 'update-app-headers' branch."
|
||||||
git checkout update-app-headers
|
git checkout update-app-headers
|
||||||
|
else
|
||||||
|
echo "Creating 'update-app-headers' branch."
|
||||||
|
git checkout -b update-app-headers origin/main
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 3: Ensure .app-headers file exists and verify content
|
# Step 4: Merge main into update-app-headers
|
||||||
- name: Ensure .app-headers file exists and verify content
|
- name: Merge main into update-app-headers
|
||||||
|
run: |
|
||||||
|
git merge origin/main --no-edit || echo "No changes to merge from main."
|
||||||
|
|
||||||
|
# Step 5: Ensure .app-headers file exists
|
||||||
|
- name: Ensure .app-headers file exists
|
||||||
run: |
|
run: |
|
||||||
if [ ! -f ".app-headers" ]; then
|
if [ ! -f ".app-headers" ]; then
|
||||||
echo "The .app-headers file does not exist. Creating it."
|
echo "Creating .app-headers file."
|
||||||
echo "Generated by CI" > .app-headers
|
echo "Generated by CI on $(date)" > .app-headers
|
||||||
else
|
else
|
||||||
echo ".app-headers already exists."
|
echo ".app-headers file already exists."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 4: Commit and push changes (if any)
|
# Step 6: Commit and push changes (if any)
|
||||||
- name: Commit and push changes (if any)
|
- name: Commit and push changes
|
||||||
run: |
|
run: |
|
||||||
git diff --quiet -- .app-headers || git commit -am "[core]: update .app-headers to latest version"
|
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 5: Create Pull Request if changes detected
|
# Step 7: Create Pull Request if changes detected
|
||||||
- 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 }}
|
||||||
@ -55,16 +66,15 @@ jobs:
|
|||||||
PR_EXISTS=$(gh pr list --head "update-app-headers" | grep -o '[0-9]\+')
|
PR_EXISTS=$(gh pr list --head "update-app-headers" | grep -o '[0-9]\+')
|
||||||
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" \
|
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 -q .url)
|
--base main
|
||||||
echo "PR created: $PR_URL"
|
|
||||||
else
|
else
|
||||||
echo "PR already exists."
|
echo "PR already exists."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 6: 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 }}
|
||||||
@ -78,7 +88,7 @@ jobs:
|
|||||||
echo "No PR found to merge."
|
echo "No PR found to merge."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 7: 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