There are some caveats for GitHub workflow and action, including yaml configuration of workflow, script composition of action, and the protection setting for corresponding branch, summarize as following for reference
Workflow
on.issues.types
If it's necessary to check label, opened
is not needed, set labeled
is enough, since even if the label is set when the issue is created, labeled
will be triggered
permissions
If it's necessary to checkout current repo, contents: write
is needed, or else there will be permission issue
jobs.check.steps.env
If it's necessary to utilize GitHub API, GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
is needed, as environmental variable
Action
List repository issues
API no only return issues, but also return prs, with default 30 records per page, labels
can be assign to filter
List pull requests
API return all the pull requests, with default 30 records per page, it's possible to fulfill pagination via per_page
and page
, such as:
const prs = [];
for (let page = 1; ; page++) {
const { data } = await octokit.rest.pulls.list({
...context.repo,
base: `refs/heads/main`,
state: 'open',
per_page: PER_PAGE,
page,
});
prs.push(...data);
if (data.length < PER_PAGE) {
break;
}
}
Get commit status
API list state of all the contexts, it's possible to filter current context
Create commit status
API,指定 state
,context
和 description
(作为运行结果显示)
API is used to create commit status, it's possible to specify state
,context
and description
(shown as running result)
Setting
Require status checks
It's necessary to check Require status checks to pass before merging under Protect matching branches in Branch protection rule
Add required checks
It's necessary to add current GitHub action to Status checks that are required
Top comments (0)