From 79a03d456118897483b9630f597421cb9c5bd9a3 Mon Sep 17 00:00:00 2001 From: soma00333 Date: Mon, 3 Feb 2025 09:43:04 +0900 Subject: [PATCH] fix(ci): add permissions to write issues and handle long title comments Signed-off-by: soma00333 --- .github/workflows/issue_title_check.yaml | 27 ++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/issue_title_check.yaml b/.github/workflows/issue_title_check.yaml index 1684c632b..94313f5f4 100644 --- a/.github/workflows/issue_title_check.yaml +++ b/.github/workflows/issue_title_check.yaml @@ -4,11 +4,15 @@ on: issues: types: [opened, edited] +permissions: + issues: write + jobs: check_title_length: runs-on: ubuntu-latest steps: - name: Check issue title length + id: check_length run: | TITLE="${{ github.event.issue.title }}" LENGTH=$(echo -n "$TITLE" | wc -m) @@ -17,19 +21,14 @@ jobs: echo "Length: $LENGTH" if [ "$LENGTH" -ge 60 ]; then - echo "Too long!" - exit 1 + echo "title_is_too_long=true" >> $GITHUB_OUTPUT + else + echo "title_is_too_long=false" >> $GITHUB_OUTPUT fi - echo "OK" - comment_if_long: - runs-on: ubuntu-latest - needs: [check_title_length] - if: always() - steps: - - name: Create comment if previous job failed + - name: Comment if title is too long + if: steps.check_length.outputs.title_is_too_long == 'true' uses: actions/github-script@v6 - if: ${{ needs.check_title_length.result == 'failure' }} with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -40,5 +39,11 @@ jobs: owner: repoOwner, repo: repoName, issue_number: issueNumber, - body: "The issue title is too long (over 60 characters). Please shorten it." + body: "The issue title is too long (over 60 characters). Please shorten it and ensure it is well summarized." }); + + - name: Fail job if title is too long + if: steps.check_length.outputs.title_is_too_long == 'true' + run: | + echo "The issue title is too long. Failing job..." + exit 1