Skip to content

Merge generated content updates #1

Merge generated content updates

Merge generated content updates #1

name: Merge generated content updates
# Trigger by cronjob
on:
schedule:
# Merge the PR every Friday at 10:00 UTC
- cron: "0 10 * * FRI"
workflow_dispatch: {} # Allow manual triggering
jobs:
merge-autogenerated-content:
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@7bfa3a4717ef143a604ee0a99d859b8886a96d00 # v1.9.3
with:
app-id: ${{ vars.AUTO_MERGE_DOCS_PRS_APP }}
private-key: ${{ secrets.AUTO_MERGE_DOCS_PRS_APP }}
- name: Checkout code
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Merge autogenerated pull request
run: |
PR_TITLE="Semi-automatic update of generated content"
# List all open pull requests
PRS=$(gh pr list -S "open" -R ${{ github.repository }} -L 100 | awk '{print $1}')
for PR in $PRS
do
# Get the title of the current pull request
CURRENT_PR_TITLE=$(gh pr view $PR -R ${{ github.repository }} --json title -q '.title')
if [ "$CURRENT_PR_TITLE" = "$PR_TITLE" ]
then
# Merge the pull request
gh pr merge $PR -R ${{ github.repository }} --merge
echo "Merged pull request #$PR"
break
fi
done
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}