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

add github actions bot with a hint comment for contributors. #147

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fsb4000
Copy link
Contributor

@fsb4000 fsb4000 commented Jul 15, 2022

Not for a merge but for demonstration for ovs-discuss@openvswitch.org

I thought about how best to reuse 0day robot checks, and I came up with the idea that it’s better not to create a pipeline with the checks, but it’s better to just tell contributors about how to submit a patch, what code style is used, and about 0day robot checks.

@fsb4000
Copy link
Contributor Author

fsb4000 commented Jul 15, 2022

Strange, the bot message works locally: fsb4000/test#1

but here I got:

{
  "message": "Resource not accessible by integration",
  "documentation_url": "https://docs.github.com/rest/reference/issues#create-an-issue-comment"
}

@fsb4000
Copy link
Contributor Author

fsb4000 commented Jul 15, 2022

I found the article: https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/

It will not work at PR before merging: fsb4000/test#2

But I hope it will work after: fsb4000/test#3

Signed-off-by: Igor Zhukov <ivzhukov@sbercloud.ru>
@fsb4000
Copy link
Contributor Author

fsb4000 commented Jul 15, 2022

An example of an other project bot message: apache/airflow#25083 (comment)

@fsb4000
Copy link
Contributor Author

fsb4000 commented Jul 27, 2022

it seems that we have openstack-mirroring bot: openstack/neutron#57 (comment)

Copy link

@jsoref jsoref left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An explanation of how/why to deal w/ permissions.

Also, best practice is to favor GH_TOKEN over GITHUB_TOKEN -- github wants to reserve the GITHUB_ environment variable prefix for its own purposes. `


jobs:
comment:
runs-on: ubuntu-latest
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
runs-on: ubuntu-latest
runs-on: ubuntu-latest
permissions:
contents: write

https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#create-an-issue

The fine-grained token must have the following permission set:

"Issues" repository permissions (write)

Default permissions for repositories depend on when the repository/user/organization/enterprise was created. Newer organizations are created with more restrictive permissions. Older entities should be upgraded to restricted permissions, but until they are, you'll be able to do things w/o declaring permissions and will experience problems trying to share those workflows to restricted containers.

https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#configuring-the-default-github_token-permissions

- name: Add comment to PR
env:
URL: ${{ github.event.pull_request.comments_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ github.token }}

-X POST \
$URL \
-H "Content-Type: application/json" \
-H "Authorization: token $GITHUB_TOKEN" \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-H "Authorization: token $GITHUB_TOKEN" \
-H "Authorization: token $GH_TOKEN" \

```\n

run: |
curl \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're using curl, but this could really be done using gh api instead.

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

Successfully merging this pull request may close these issues.

2 participants