-
Notifications
You must be signed in to change notification settings - Fork 31
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
Compliant Updates #56
Open
nyarly
wants to merge
6
commits into
DeterminateSystems:main
Choose a base branch
from
nyarly:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6f9fc6e
Use gh CLI to make (verified) commit
nyarly 1ee5a6c
Create the branch only if needed
nyarly 8e2a4ea
Document how to get compliant updates
nyarly caae4dc
CI feedback
nyarly 10aa0b3
Update README.md
nyarly d8c2852
Update README.md
nyarly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -9,6 +9,10 @@ inputs: | |
description: 'GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT)' | ||
required: false | ||
default: ${{ github.token }} | ||
commit-with-token: | ||
description: 'Set to "true" to produce a verified commit with token' | ||
required: false | ||
default: '' | ||
commit-msg: | ||
description: 'The message provided with the commit' | ||
required: false | ||
|
@@ -119,6 +123,36 @@ runs: | |
TARGETS: ${{ inputs.inputs }} | ||
COMMIT_MSG: ${{ inputs.commit-msg }} | ||
PATH_TO_FLAKE_DIR: ${{ inputs.path-to-flake-dir }} | ||
COMMIT_WITH_TOKEN: ${{ inputs.commit-with-token }} | ||
|
||
- name: Commit changes | ||
if: ${{ inputs.commit-with-token == 'true' }} | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.token }} | ||
FILE_TO_COMMIT: flake.lock | ||
DESTINATION_BRANCH: ${{ inputs.branch }} | ||
shell: bash | ||
run: | | ||
set -x | ||
export CONTENT=$( base64 -i $FILE_TO_COMMIT ) | ||
export BASE=$DESTINATION_BRANCH | ||
if gh api --method GET /repos/:owner/:repo/git/refs/heads/$DESTINATION_BRANCH; then | ||
git fetch origin $DESTINATION_BRANCH | ||
else | ||
export BASE=$(gh repo view --json defaultBranchRef --template '{{ .defaultBranchRef.name }}' ${{github.repository}}) | ||
export BASE_SHA=$( git rev-parse origin/$BASE ) | ||
gh api --method POST /repos/:owner/:repo/git/refs \ | ||
--field ref=refs/heads/$DESTINATION_BRANCH \ | ||
--field sha=$BASE_SHA | ||
fi | ||
export BASE_SHA=$( git rev-parse origin/$BASE ) | ||
export SHA=$( git rev-parse origin/$BASE:$FILE_TO_COMMIT ) | ||
gh api --method PUT /repos/:owner/:repo/contents/$FILE_TO_COMMIT \ | ||
--field message="${{inputs.commit-msg}}" \ | ||
--field content="$CONTENT" \ | ||
--field encoding="base64" \ | ||
--field branch="$DESTINATION_BRANCH" \ | ||
--field sha="$SHA" | ||
- name: Save PR Body as file | ||
uses: DamianReeves/[email protected] | ||
with: | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than dealing with the "get a verified-by-github commit" ourselves, I would much rather call out to an action or two that do this for us. And it just so happens that there is a combination of actions we can use to get the same result:
You can see it works here: cole-h/test#7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me try this on my fork