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: update periodic reporter #93

Merged
merged 1 commit into from
May 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions .github/workflows/periodic-reporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
owner: 'GoogleCloudPlatform',
repo: 'terraform-google-secure-cicd',
state: 'open',
creator: 'github-actions[bot]',
labels: [periodicLabel]
});
// createOrCommentIssue creates a new issue or comments on an existing issue.
Expand All @@ -53,16 +54,23 @@ jobs:
});
return;
}
console.log(`found previous issue ${prevIssues[0].html_url}, adding comment`);
if (prevIssues.length > 1) {
console.warn(
`found ${prevIssues.length} issues but only adding comment to ${prevIssues[0].html_url}`
);
}
console.log(
`found previous issue ${prevIssues[0].html_url}, adding comment`
);
await github.rest.issues.createComment({
...context.repo,
issue_number: prevIssues[0].number,
body: txt
});
};

// updateAndCloseIssue comments on an existing issue and closes it. No-op if no issue exists.
const updateAndCloseIssue = async function (txt) {
// updateAndCloseIssues comments on any existing issues and closes them. No-op if no issue exists.
const updateAndCloseIssues = async function (txt) {
if (prevIssues.length < 1) {
console.log('no previous issues found, skipping close');
return;
Expand All @@ -79,7 +87,7 @@ jobs:
...context.repo,
issue_number: prevIssue.number,
body: txt,
state: "closed",
state: 'closed'
});
}
};
Expand Down Expand Up @@ -118,7 +126,7 @@ jobs:
periodicCheck.status === 'completed' &&
periodicCheck.conclusion === 'success'
) {
updateAndCloseIssue(
updateAndCloseIssues(
`[Passing periodic](${periodicCheck.html_url}) at ${commit.html_url}. Closing this issue.`
);
} else if (periodicCheck.status === 'in_progress') {
Expand Down