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

chore: retain waiting for user response label if comment posted by user that added label #1835

Merged
merged 14 commits into from
Feb 21, 2024
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"]
});
});
Loading