-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub Action: 更新
update_contributors_images.yaml
, 支持签名提交
添加`ci_commit_with_signature.sh`脚本, 使用`GraphQL Api`实现提交签名, 提交者受`api`的制约不能更改
- Loading branch information
Showing
2 changed files
with
53 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,16 +33,12 @@ jobs: | |
run: | | ||
sed -i "s/@version\s*[^\\s]*/@version $(TZ='Asia/Shanghai' date +'%Y-%m-%d')/" main.user.js | ||
- name: Commit file main.user.js | ||
- name: Commit and push main.user.js | ||
if: ${{ env.AHEAD == 'true' }} | ||
run: | | ||
git config --local user.name "github-actions[bot]" | ||
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git add main.user.js | ||
git commit -m "main.user.js Update to version $(TZ='Asia/Shanghai' date +'%Y-%m-%d')" | ||
- name: Push changes | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.CI_GITHUB_TOKEN }} | ||
branch: ${{ github.ref }} | ||
bash script/ci.sh \ | ||
${{ secrets.CI_GITHUB_TOKEN }} \ | ||
"maboloshi/github-chinese" \ | ||
"main.user.js" \ | ||
"main.user.js Update to version $(TZ='Asia/Shanghai' date +'%Y-%m-%d')" | ||
"Signed-off-by: 沙漠之子 <[email protected]>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
TOKEN=$1 | ||
repoNwo=$2 | ||
branch=$(git rev-parse --abbrev-ref HEAD) # 或 git rev-parse HEAD | ||
file_path=$3 | ||
encoded_file_content=$(base64 < "$file_path") | ||
message_headline=$4 | ||
message_body=$5 | ||
expectedHeadOid=$(git rev-parse HEAD) | ||
|
||
curl $GITHUB_GRAPHQL_URL --silent \ | ||
--write-out '%{stderr}HTTP status: %{response_code}\n\n' \ | ||
-H "Authorization: bearer $TOKEN" \ | ||
--data @- <<GRAPHQL | jq | ||
{ | ||
"query": "mutation (\$input: CreateCommitOnBranchInput!) { | ||
createCommitOnBranch(input: \$input) { | ||
commit { | ||
url | ||
} | ||
} | ||
}", | ||
"variables": { | ||
"input": { | ||
"branch": { | ||
"repositoryNameWithOwner": "$repoNwo", | ||
"branchName": "$branch" | ||
}, | ||
"message": { | ||
"headline": "$message_headline", | ||
"body": "$message_body" | ||
}, | ||
"fileChanges": { | ||
"additions": [ | ||
{ | ||
"path": "$file_path", | ||
"contents": "$encoded_file_content" | ||
} | ||
] | ||
}, | ||
"expectedHeadOid": "$expectedHeadOid" | ||
} | ||
} | ||
} | ||
GRAPHQL |