diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 25b4598..0082d06 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -71,13 +71,15 @@ When a Konflux build check fails on a pull request, this action will automatical |-------|-------------|----------|---------| | `max_retries` | Maximum number of retries for failed builds | No | `3` | | `check_name_suffix` | Suffix to filter Konflux build check names (e.g., `-on-push`) | No | `-on-push` | +| `retest_command` | Command to trigger Konflux retest (e.g., /retest). Useful to use non default when OpenShift CI uses the same /retest syntax - prevents OpenShift CI from spamming comments saying it does not understand Konflux-specific retest commands. | No | `/retest` | ## Detailed options -- **Automatic Retesting**: Posts `/retest` commands when Konflux builds fail +- **Automatic Retesting**: Posts retest commands when Konflux builds fail - **Configurable Retry Limit**: Set maximum retry attempts to prevent infinite loops -- **Auto-Cleanup**: Removes old `/retest` comments when new commits are pushed +- **Auto-Cleanup**: Removes old retest comments when new commits are pushed - **Filtered Checks**: Only retests checks matching a specific name suffix (e.g., `-on-push`) +- **Custom Retest Command**: Configure the command used to trigger retests (default: `/retest`) ### Usage @@ -102,4 +104,5 @@ jobs: with: max_retries: 3 check_name_suffix: '-on-push' + retest_command: '/retest' ``` diff --git a/.github/workflows/retest-konflux-builds.yml b/.github/workflows/retest-konflux-builds.yml index 8bbb70d..a2a67e1 100644 --- a/.github/workflows/retest-konflux-builds.yml +++ b/.github/workflows/retest-konflux-builds.yml @@ -1,5 +1,5 @@ # There are two kind of comments in the GitHub pull request: conversation comments and pull request review comments. -# Konflux monitors `/retest` conversation comments for rerunning pipelines. +# Konflux monitors retest conversation comments (configurable, default: `/retest`) for rerunning pipelines. # The conversation comments belong to `/issues/` Github API. name: Retest Failed Konflux Builds @@ -17,6 +17,11 @@ on: required: false type: string default: '-on-push' + retest_command: + description: 'Command to trigger Konflux retest (e.g., /retest). Useful to use non default when OpenShift CI uses the same /retest syntax - prevents OpenShift CI from spamming comments saying it does not understand Konflux-specific retest commands.' + required: false + type: string + default: '/retest' jobs: cleanup-retest-comments: @@ -30,20 +35,21 @@ jobs: issues: write steps: - - name: Remove existing /retest comments as new commits were pushed + - name: Remove existing retests comments env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RETEST_COMMAND: ${{ inputs.retest_command }} run: | PR_NUMBER="${{ github.event.pull_request.number }}" - echo "New commit pushed to PR #$PR_NUMBER. Cleaning up existing /retest comments from GitHub Actions..." + echo "New commit pushed to PR #$PR_NUMBER. Cleaning up existing $RETEST_COMMAND comments from GitHub Actions..." - # Get all comments from github-actions bot containing /retest and ending with CHECK_NAME_SUFFIX + # Get all comments from github-actions bot containing retest command and ending with CHECK_NAME_SUFFIX COMMENT_IDS=$(gh api --paginate "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \ - --jq '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("/retest") and endswith("${{ inputs.check_name_suffix }}"))) | .id') + --jq '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("'"$RETEST_COMMAND"'") and endswith("${{ inputs.check_name_suffix }}"))) | .id') if [ -z "$COMMENT_IDS" ]; then - echo "No /retest comments found to clean up" + echo "No $RETEST_COMMAND comments found to clean up" else # Delete each comment for COMMENT_ID in $COMMENT_IDS; do @@ -73,6 +79,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MAX_RETRIES: ${{ inputs.max_retries }} CHECK_NAME_SUFFIX: ${{ inputs.check_name_suffix }} + RETEST_COMMAND: ${{ inputs.retest_command }} run: | CHECK_NAME="${{ github.event.check_run.name }}" @@ -88,11 +95,11 @@ jobs: # Count comments containing the retest command (fetches all comments via pagination) RETRY_COUNT="$(gh api --paginate "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \ - --jq '[.[] | select(.body | contains("/retest '"$CHECK_NAME"'"))] | length')" + --jq '[.[] | select(.body | contains("'"$RETEST_COMMAND"' '"$CHECK_NAME"'"))] | length')" if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then echo "::warning::Maximum retry limit ($MAX_RETRIES) reached for $CHECK_NAME on PR #$PR_NUMBER" else echo "Retrying $CHECK_NAME (attempt $((RETRY_COUNT + 1))/$MAX_RETRIES)" - gh pr comment "$PR_NUMBER" --repo ${{ github.repository }} --body "/retest $CHECK_NAME" + gh pr comment "$PR_NUMBER" --repo ${{ github.repository }} --body "$RETEST_COMMAND $CHECK_NAME" fi