merge-hack-pull-requests #1300
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: merge-hack-pull-requests | |
| on: | |
| schedule: | |
| - cron: '0 * * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| issues: write | |
| repository-projects: write | |
| jobs: | |
| bulk-merge: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install yq | |
| run: | | |
| sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq | |
| sudo chmod +x /usr/local/bin/yq | |
| - name: Process All Repos | |
| env: | |
| GH_TOKEN: ${{ secrets.OPENSHIFT_PIPELINES_ROBOT }} | |
| ORG_NAME: "openshift-pipelines" | |
| TARGET_LABEL: "hack" | |
| run: | | |
| echo "Getting repository list..." | |
| REPOS=$(yq -N e 'env(ORG_NAME) + "/" + (.repo // .name)' config/downstream/repos/*.yaml; echo "$ORG_NAME/hack" | sort -u) | |
| for REPO in $REPOS; do | |
| echo "Searching $REPO for PRs with label: $TARGET_LABEL" | |
| PR_NUMS=$(gh pr list -R "$REPO" --label "$TARGET_LABEL" --json number --jq '.[].number') | |
| if [[ -z "$PR_NUMS" ]]; then | |
| echo "No PRs found in $REPO" | |
| continue | |
| fi | |
| for p in $PR_NUMS; do | |
| echo "Attempting to merge PR #$p in $REPO..." | |
| gh pr edit $p --add-label "lgtm" --add-label "approved" || true | |
| gh pr merge "$p" -R "$REPO" --rebase --auto || true | |
| done | |
| done |