1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-02-02 10:51:51 +00:00
ProxmoxVE/.github/workflows/generate-app-headers.yaml

82 lines
2.8 KiB
YAML
Raw Normal View History

name: Update .app-headers in /misc
on:
push:
branches: ["main"]
workflow_dispatch:
jobs:
2025-01-10 12:04:38 +01:00
update-and-merge-pr:
runs-on: ubuntu-latest
permissions:
2025-01-10 12:04:38 +01:00
contents: write
pull-requests: write
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.CREATE_HEADER_APP_ID }}
2025-01-10 12:04:38 +01:00
private-key: ${{ secrets.CREATE_HEADER_SECRET }}
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Figlet
run: sudo apt-get install -y figlet
- name: Run generate-app-headers script
run: |
bash .github/workflows/generate-app-headers.sh
2025-01-10 12:04:38 +01:00
- name: Create or update branch
run: |
2025-01-10 12:17:44 +01:00
# Check if the branch exists, and create it if not
2025-01-10 12:04:38 +01:00
git fetch origin
git checkout -b update-app-headers || git checkout update-app-headers
2025-01-10 12:06:37 +01:00
# Configure Git user info
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
2025-01-10 12:17:44 +01:00
# Make sure there are changes to commit
2025-01-10 12:15:52 +01:00
git diff --quiet || git commit -am "[core]: update .app-headers to latest version"
2025-01-10 12:04:38 +01:00
2025-01-10 12:17:44 +01:00
# Push changes to the branch if there are any
2025-01-10 12:15:52 +01:00
git push origin update-app-headers --force || echo "No changes to push"
2025-01-10 12:04:38 +01:00
2025-01-10 12:19:11 +01:00
- name: Check if there are changes before creating PR
id: check-changes
run: |
2025-01-10 12:22:57 +01:00
# Check if there are any changes between 'main' and 'update-app-headers'
2025-01-10 12:19:11 +01:00
git fetch origin
git diff --quiet origin/main..update-app-headers || echo "Changes detected" > changes.txt
if [ ! -f changes.txt ]; then
echo "No changes detected, skipping PR creation."
2025-01-10 12:22:57 +01:00
exit 0 # Exit successfully if no changes are found
2025-01-10 12:19:11 +01:00
fi
2025-01-10 12:04:38 +01:00
- name: Create pull request
id: create-pr
2025-01-10 12:22:57 +01:00
if: steps.check-changes.outcome == 'success' # Only create PR if changes are detected
2025-01-10 12:08:30 +01:00
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2025-01-10 12:04:38 +01:00
run: |
PR_EXISTS=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
if [ -z "$PR_EXISTS" ]; then
2025-01-10 12:17:44 +01:00
# Create the pull request if it doesn't exist
2025-01-10 12:14:09 +01:00
gh pr create --title "[core]: update .app-headers to latest version" \
2025-01-10 12:04:38 +01:00
--body "This PR automatically updates the app-headers file." \
--head update-app-headers \
2025-01-10 12:09:27 +01:00
--base main
2025-01-10 12:21:27 +01:00
else
echo "PR already exists, skipping creation."
2025-01-10 12:04:38 +01:00
fi
2025-01-10 12:21:27 +01:00
- name: Final Status
run: |
2025-01-10 12:37:52 +01:00
echo "Workflow completed successfully."