ProxmoxVE/.github/workflows/generate-app-headers.yaml

86 lines
2.7 KiB
YAML
Raw Normal View History

name: Update .app-headers in /misc
on:
push:
branches: ["main"]
workflow_dispatch:
jobs:
2025-01-10 11:04:38 +00:00
update-and-merge-pr:
runs-on: ubuntu-latest
permissions:
2025-01-10 11:04:38 +00: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 11:04:38 +00: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 11:04:38 +00:00
- name: Create or update branch
run: |
# Check if the branch exists
git fetch origin
git checkout -b update-app-headers || git checkout update-app-headers
2025-01-10 11:06:37 +00: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 11:04:38 +00:00
# Make your changes, e.g., update app-headers file
echo "update app-headers to latest" >> misc/.app-headers
git add misc/.app-headers
git commit -m "update app-headers to latest"
# Push changes to the branch
git push origin update-app-headers --force
- name: Create pull request
id: create-pr
2025-01-10 11:08:30 +00:00
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2025-01-10 11:04:38 +00:00
run: |
PR_EXISTS=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
if [ -z "$PR_EXISTS" ]; then
gh pr create --title "Update app-headers to latest" \
--body "This PR automatically updates the app-headers file." \
--head update-app-headers \
2025-01-10 11:09:27 +00:00
--base main
2025-01-10 11:04:38 +00:00
fi
- name: Approve pull request
if: steps.create-pr.outputs.pr_exists == 'true'
2025-01-10 11:08:30 +00:00
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2025-01-10 11:04:38 +00:00
run: |
PR_NUMBER=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
if [ -n "$PR_NUMBER" ]; then
gh pr review $PR_NUMBER --approve --body "Approved automatically by GitHub Action."
fi
- name: Merge pull request
if: steps.create-pr.outputs.pr_exists == 'true'
2025-01-10 11:08:30 +00:00
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
2025-01-10 11:04:38 +00:00
PR_NUMBER=$(gh pr list --head "update-app-headers" --json number --jq '.[].number')
if [ -n "$PR_NUMBER" ]; then
gh pr merge $PR_NUMBER --merge --auto --delete-branch
fi