mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-01-11 11:25:08 +00:00
76 lines
2.5 KiB
YAML
76 lines
2.5 KiB
YAML
name: Update .app-headers in /misc
|
|
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
update-and-merge-pr:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
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 }}
|
|
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
|
|
|
|
- name: Create or update branch
|
|
run: |
|
|
# Check if the branch exists, and create it if not
|
|
git fetch origin
|
|
git checkout -b update-app-headers || git checkout update-app-headers
|
|
|
|
# Configure Git user info
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
# Make sure there are changes to commit
|
|
git diff --quiet || git commit -am "[core]: update .app-headers to latest version"
|
|
|
|
# Push changes to the branch if there are any
|
|
git push origin update-app-headers --force || echo "No changes to push"
|
|
|
|
- name: Create pull request
|
|
id: create-pr
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
PR_EXISTS=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
|
|
if [ -z "$PR_EXISTS" ]; then
|
|
# Create the pull request if it doesn't exist
|
|
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
|
|
fi
|
|
|
|
- name: Merge pull request (Squash and Merge)
|
|
if: steps.create-pr.outputs.pr_exists == 'true'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
# Get the PR number and merge it if it exists
|
|
PR_NUMBER=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
|
|
if [ -n "$PR_NUMBER" ]; then
|
|
# Squash and merge the PR automatically
|
|
gh pr merge $PR_NUMBER --squash --auto --delete-branch
|
|
fi
|