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

Update comments mentioning workflow runs when said workflow runs completed #9

Open
dscho opened this issue Dec 12, 2022 · 1 comment

Comments

@dscho
Copy link
Member

dscho commented Dec 12, 2022

When a slash command needs a GitHub workflow to be triggered, GitForWindowsHelper updates the comment containing that slash command with a link to the workflow run.

It would be nice if that comment was further modified when said workflow run completes.

This might require a little change in how the comments are edited: we might need to add a tell-tale that can be found via the Search API, as we cannot easily search for comments that were edited by the GitForWindowsHelper. It could be a comment (think <!-- added by GitForWindowsHelper: workflow run <id> was triggered -->).

@dscho
Copy link
Member Author

dscho commented Dec 13, 2022

A code snippet to test this idea:

const httpsRequest = require('./GitForWindowsHelper/https-request');

(async () => {
    const answer = await httpsRequest(
        console,
        'api.github.com',
        'GET',
        `/search/issues?q=${encodeURIComponent('"gitforwindowshelper[bot] triggered run git-for-windows/build-extra/3602581986"')}`,
        null, {
            Accept: 'application/vnd.github.text-match+json'
        }
    )
    console.log(answer.items[0].text_matches)
    console.log(answer.items[0].text_matches[0].matches)
})().catch(console.log)

It outputs:

[
  {
    object_url: 'https://api.github.com/repositories/23216272/issues/comments/1335323877',
    object_type: 'IssueComment',
    property: 'body',
    fragment: '/add relnote\n' +
      '\n' +
      '!-- gitforwindowshelper[bot] triggered run git-for-windows/build-extra/3602581986 -- The workflow run was started\n' +
      '\n' +
      'EDIT: I had a typo in the workflow definition, fixed in git-for-windows/build-extra@2cbd6af8f. Knock on wood.\n',
    matches: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object]
    ]
  }
]
[
  { text: 'gitforwindowshelper', indices: [ 18, 37 ] },
  { text: 'bot', indices: [ 38, 41 ] },
  { text: 'triggered run git', indices: [ 43, 60 ] },
  { text: 'for', indices: [ 61, 64 ] },
  { text: 'windows', indices: [ 65, 72 ] },
  { text: 'build', indices: [ 73, 78 ] },
  { text: 'extra', indices: [ 79, 84 ] },
  { text: '3602581986', indices: [ 85, 95 ] }
]

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

No branches or pull requests

1 participant