|
1 | 1 | # Generated for Konflux Application openshift-pipelines-cli by openshift-pipelines/hack. DO NOT EDIT |
2 | | -name: auto-merge-upstream-tektoncd-cli |
3 | | - |
| 2 | +name: auto-merge-upstream-tektoncd/cli |
4 | 3 | on: |
5 | 4 | workflow_dispatch: {} |
6 | 5 | schedule: |
7 | | - - cron: "*/30 * * * *" # At every 30 minutes |
| 6 | + - cron: "0,30 * * * *" |
| 7 | +concurrency: |
| 8 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 9 | + cancel-in-progress: true |
8 | 10 |
|
9 | 11 | jobs: |
10 | | - auto-approve: |
| 12 | + collect-branches: |
11 | 13 | runs-on: ubuntu-latest |
12 | | - permissions: |
13 | | - pull-requests: write |
| 14 | + outputs: |
| 15 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
14 | 16 | steps: |
15 | | - - name: Checkout the current repo |
16 | | - uses: actions/checkout@v4 |
17 | | - - name: auto-merge-upstream-tektoncd-cli |
18 | | - run: | |
19 | | - gh auth status |
20 | | - git config user.name openshift-pipelines-bot |
21 | | - git config user.email pipelines-extcomm@redhat.com |
22 | | - # Approve and merge pull-request with no reviews |
23 | | - for p in $(gh pr list --search "head:actions/update/sources-tektoncd-cli" --json "number" | jq ".[].number"); do |
24 | | - gh pr merge --rebase --delete-branch --auto $p |
25 | | - done |
26 | | - env: |
27 | | - GH_TOKEN: ${{ secrets.OPENSHIFT_PIPELINES_ROBOT }} |
28 | | - |
| 17 | + - name: Get branches matching pattern |
| 18 | + id: set-matrix |
| 19 | + run: | |
| 20 | + # List all branches and filter |
| 21 | + branches=$(gh api repos/${{ github.repository }}/branches --paginate -q '.[] | .name' | grep -E '^(release-v.*\.x$|next$)') |
| 22 | + echo "Found branches:" |
| 23 | + echo "$branches" |
| 24 | + # Convert to JSON array for matrix |
| 25 | + json=$(jq -nc --argjson arr "$(printf '%s\n' "$branches" | jq -R . | jq -s .)" '{branch: $arr}') |
| 26 | + echo "Matrix JSON: $json" |
| 27 | + echo "matrix=$json" >> $GITHUB_OUTPUT |
| 28 | + env: |
| 29 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + auto-merge-upstream-all: |
| 31 | + needs: collect-branches |
| 32 | + runs-on: ubuntu-latest |
| 33 | + strategy: |
| 34 | + fail-fast: false |
| 35 | + matrix: ${{ fromJSON(needs.collect-branches.outputs.matrix) }} |
| 36 | + steps: |
| 37 | + - name: Trigger auto-merge-upstream for ${{ matrix.branch }} |
| 38 | + env: |
| 39 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + run: | |
| 41 | + echo Triggering workflow for branch: ${{ matrix.branch }} |
| 42 | + |
| 43 | + gh workflow run "auto-merge-upstream.yaml" \ |
| 44 | + --ref ${{ matrix.branch }} \ |
| 45 | + --repo ${{ github.repository }} |
0 commit comments