|
| 1 | +# |
| 2 | +# Copyright (c) 2026 Red Hat, Inc. |
| 3 | +# This program and the accompanying materials are made |
| 4 | +# available under the terms of the Eclipse Public License 2.0 |
| 5 | +# which is available at https://www.eclipse.org/legal/epl-2.0/ |
| 6 | +# |
| 7 | +# SPDX-License-Identifier: EPL-2.0 |
| 8 | +# |
| 9 | + |
| 10 | +# |
| 11 | +# This file was generated using AI assistance (Cursor AI) |
| 12 | +# and reviewed by the maintainers. |
| 13 | +# |
| 14 | + |
| 15 | +name: Trigger Rebase via dw-claude-runner |
| 16 | + |
| 17 | +on: |
| 18 | + issue_comment: |
| 19 | + types: [created] |
| 20 | + |
| 21 | +jobs: |
| 22 | + trigger-rebase: |
| 23 | + if: >- |
| 24 | + !github.event.issue.pull_request |
| 25 | + && contains(github.event.issue.title, 'Alignment Che-Code with') |
| 26 | + && contains(github.event.comment.body, '/rebase') |
| 27 | + runs-on: ubuntu-22.04 |
| 28 | + permissions: |
| 29 | + issues: write |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Check author permission |
| 33 | + id: permission |
| 34 | + env: |
| 35 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + run: | |
| 37 | + PERM=$(gh api "repos/${{ github.repository }}/collaborators/${{ github.event.comment.user.login }}/permission" \ |
| 38 | + --jq '.permission') |
| 39 | + echo "permission=$PERM" |
| 40 | + if [[ "$PERM" != "admin" && "$PERM" != "write" ]]; then |
| 41 | + echo "User ${{ github.event.comment.user.login }} does not have write access (permission: $PERM)" |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | +
|
| 45 | + - name: Add reaction to comment |
| 46 | + env: |
| 47 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + run: | |
| 49 | + gh api "repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions" \ |
| 50 | + -f content='rocket' --silent |
| 51 | +
|
| 52 | + - name: Checkout dw-claude-runner |
| 53 | + uses: actions/checkout@v4 |
| 54 | + with: |
| 55 | + repository: RomanNikitenko/dw-claude-runner |
| 56 | + path: dw-claude-runner |
| 57 | + |
| 58 | + - name: Install oc CLI |
| 59 | + uses: redhat-actions/openshift-tools-installer@v1 |
| 60 | + with: |
| 61 | + oc: latest |
| 62 | + |
| 63 | + - name: Login to OpenShift |
| 64 | + run: | |
| 65 | + oc login --token=${{ secrets.OC_TOKEN }} \ |
| 66 | + --server=${{ secrets.OC_SERVER }} |
| 67 | +
|
| 68 | + - name: Run dw-claude-runner |
| 69 | + working-directory: dw-claude-runner |
| 70 | + env: |
| 71 | + PROJECT_URL: '"https://github.com/${{ github.repository }}.git"' |
| 72 | + TARGET_REPO: ${{ github.repository }} |
| 73 | + SKILL_SOURCE: target_project |
| 74 | + SKILL_PATH: .claude/skills/test-pr.md |
| 75 | + run: ./run.sh -v 2>&1 | tee /tmp/runner-output.txt |
| 76 | + |
| 77 | + - name: Extract PR URL |
| 78 | + if: success() |
| 79 | + id: extract-pr |
| 80 | + run: | |
| 81 | + PR_URL=$(grep -oE 'https://github.com/[^/]+/[^/]+/pull/[0-9]+' /tmp/runner-output.txt | tail -1 || true) |
| 82 | + echo "pr_url=${PR_URL}" >> "$GITHUB_OUTPUT" |
| 83 | +
|
| 84 | + - name: Comment success on issue |
| 85 | + if: success() |
| 86 | + env: |
| 87 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + PR_URL: ${{ steps.extract-pr.outputs.pr_url }} |
| 89 | + run: | |
| 90 | + BODY="Rebase workflow **succeeded**. [View run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" |
| 91 | + if [ -n "$PR_URL" ]; then |
| 92 | + BODY="${BODY}\n\nCreated PR: ${PR_URL}" |
| 93 | + fi |
| 94 | + gh issue comment "${{ github.event.issue.number }}" \ |
| 95 | + --repo "${{ github.repository }}" \ |
| 96 | + --body "$(echo -e "$BODY")" |
| 97 | +
|
| 98 | + - name: Comment failure on issue |
| 99 | + if: failure() |
| 100 | + env: |
| 101 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 102 | + run: | |
| 103 | + gh issue comment "${{ github.event.issue.number }}" \ |
| 104 | + --repo "${{ github.repository }}" \ |
| 105 | + --body "Rebase workflow **failed**. [View run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" |
0 commit comments