-
Notifications
You must be signed in to change notification settings - Fork 260
Open
Description
When using the GITHUB_TOKEN via git the resulting commits show up as unverified.
If the same commits are made with the GITHUB_TOKEN through the graphql api (as discussed here https://gist.github.com/swinton/03e84635b45c78353b1f71e41007fc7c?permalink_comment_id=5401086#gistcomment-5401086 ):
Referencing a dev.to post about making commits using gh's graphql api, Here's a solution that can handle an arbitrary number of files:
# Collect all changed file names CHANGED=($(git diff --name-only | xargs)) for value in "${CHANGED[@]}"; do FILES="${FILES} -F files[][path]=$value -F files[][contents]=$(base64 -w0 $value)" done gh api graphql \ -F githubRepository=${GIT_REPOSITORY} \ -F branchName=${PUBLISH_BRANCH} \ -F expectedHeadOid=$(git rev-parse HEAD) \ -F commitMessage="commit by github-actions[bot]" \ -F "query=@.github/api/createCommitOnBranch.gql" \ ${FILES}You do need to create the
.github/api/createCommitOnBranch.gqlfile:mutation ( $githubRepository: String!, $branchName: String!, $expectedHeadOid: GitObjectID! $commitMessage: String! $files: [FileAddition!]! ) { createCommitOnBranch( input: { branch: { repositoryNameWithOwner: $githubRepository, branchName: $branchName }, message: {headline: $commitMessage}, fileChanges: { additions: $files } expectedHeadOid: $expectedHeadOid } ){ commit { url } } }
The resulting commits appear as signed/verified.
Reactions are currently unavailable