Skip to content

Commit

Permalink
chore: retain waiting for user response label if comment posted by …
Browse files Browse the repository at this point in the history
…user that added label (#1835)

* Update issue-comment.yml

* Update issue-comment.yml

* Update issue-comment.yml

* Update issue-comment.yml

* Update issue-comment.yml

* Update issue-comment.yml

* Update issue-comment.yml

* Update issue-comment.yml

* Update issue-comment.yml

* Update issue-comment.yml

* Update issue-comment.yml

* Update issue-comment.yml

* Update issue-comment.yml
  • Loading branch information
josxha authored Feb 21, 2024
1 parent e49cac7 commit e0bec8b
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/issue-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,27 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: issue } = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const isStale = issue.labels.some(label => label.name === 'stale');
const waitingResponse = issue.labels.some(label => label.name === 'waiting for user response');
return !isStale && waitingResponse;
console.log("isStale: " + isStale);
if (isStale) return false;
const { data: events } = await github.rest.issues.listEvents({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const labelAddedEvent = events.findLast(event => event.event === 'labeled' && event.label.name === 'waiting for user response');
if (!labelAddedEvent) return false;
const labelAddedDate = new Date(labelAddedEvent.created_at);
const now = new Date();
const secondsSinceLabelAdded = (now - labelAddedDate) / 1000;
console.log(secondsSinceLabelAdded + "s")
return secondsSinceLabelAdded > 30;
# only remove the label if the issue is not stale, this prevents that this
# action removes the label when the automatic reminder message gets sent.
- name: Remove `waiting for user response` label if exists
Expand All @@ -37,4 +51,4 @@ jobs:
repo: context.repo.repo,
issue_number: context.issue.number,
name: ["waiting for user response"]
});
});

0 comments on commit e0bec8b

Please sign in to comment.