Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: action to modify issue/PR TargetDate when a special comment is posted #9

Open
kelly-sovacool opened this issue Aug 20, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@kelly-sovacool
Copy link
Member

kelly-sovacool commented Aug 20, 2024

Description of feature

This would allow Trello x Unito to adjust the TargetDate field so the GitHub Project gantt chart matches Trello.

Trello allows issues (cards) to depend on each other, while GitHub Projects lack this feature.

@phoman14

@kelly-sovacool kelly-sovacool added the enhancement New feature or request label Aug 20, 2024
@kelly-sovacool
Copy link
Member Author

related to #7

@phoman14
Copy link

@kelly-sovacool
ok i tried something and i don't know how to see if this even makes sense but i used chatGTP to try and create the YAML for this type of action. It definitely needs editing to do the specific action we want but it may be a start
name: Update Issue TargetDate on Comment
Prompt: create YAML for Github action that will update issue TargetDate when specific comment is added to issue
Result:

on:
issue_comment:
types: [created]

jobs:
update-target-date:
runs-on: ubuntu-latest

steps:
  - name: Check comment for target date update
    id: check_comment
    run: |
      COMMENT_BODY="${{ github.event.comment.body }}"
      TARGET_DATE_REGEX="Update TargetDate to (\d{4}-\d{2}-\d{2})"
      
      if [[ $COMMENT_BODY =~ $TARGET_DATE_REGEX ]]; then
        TARGET_DATE="${BASH_REMATCH[1]}"
        echo "TARGET_DATE=$TARGET_DATE" >> $GITHUB_ENV
      else
        echo "No target date update found in comment."
        exit 0
      fi

  - name: Update issue with target date
    if: env.TARGET_DATE
    uses: actions/github-script@v6
    with:
      script: |
        const issueNumber = context.issue.number;
        const targetDate = process.env.TARGET_DATE;
        
        await github.issues.update({
          ...context.repo,
          issue_number: issueNumber,
          labels: ['TargetDate'],
          body: `The TargetDate has been updated to ${targetDate}.`
        });

        await github.issues.createComment({
          ...context.repo,
          issue_number: issueNumber,
          body: `The issue TargetDate has been successfully updated to ${targetDate}.`
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants