Repository navigation
chore: add skills - update dictionary and verified commit #5057
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
Open
jesmrec
wants to merge
6
commits into
master
Choose a base branch
from
technical/add_skill_update_dictionary
base: master
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.
+439
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
25ee6cf
chore: add skill to create ui elements dictionary
jesmrec 307871c
chore: call the dictionary skill from the archive
jesmrec c49d8a1
chore: add git-signed-commit skill
jesmrec 382d784
chore: support force parameter to build the dictionary regardless of …
jesmrec 4bb2546
chore: add calens file
jesmrec 700ae0f
chore: enforce git-signed-commit for android-scenario-testing commits…
jesmrec 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 hidden or 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 hidden or 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,161 @@ | ||
| --- | ||
| name: git-signed-commit | ||
| description: Creates a GPG-signed commit on a remote GitHub repo via the Git Data API, verifying that GitHub marks it as Verified. Accepts REPO, TREE_SHA, PARENT_SHA, and COMMIT_MESSAGE as inputs; reads author identity and signing key from local git config. | ||
| --- | ||
|
|
||
| Create a GPG-signed commit in a remote GitHub repository using the Git Data API. The commit is signed locally and GitHub verifies it against the public key registered on the account. | ||
|
|
||
| **Inputs** — substitute each placeholder in the bash block before running it: | ||
|
|
||
| | Placeholder | Description | | ||
| |---|---| | ||
| | `<REPO>` | GitHub repository in `owner/name` form (e.g. `owncloud/android-scenario-testing`) | | ||
| | `<TREE_SHA>` | SHA of the git tree object the commit should point to | | ||
| | `<PARENT_SHA>` | SHA of the parent commit | | ||
| | `<COMMIT_MESSAGE>` | First-line commit message (e.g. `chore: update ui elements dictionary`). A DCO sign-off line is appended automatically from git config. | | ||
|
|
||
| **Prerequisites:** | ||
|
|
||
| - `gh` CLI must be authenticated with write access to `<REPO>` | ||
| - GPG key configured (`git config user.signingkey` or a key matching `user.email`). If the key has a passphrase and is not already unlocked in the agent, a pinentry dialog will appear for the user to enter it (requires pinentry-mac on macOS for GUI prompt) | ||
|
|
||
| --- | ||
|
|
||
| ## Step — Sign and create commit | ||
|
|
||
| Substitute `<REPO>`, `<TREE_SHA>`, `<PARENT_SHA>`, and `<COMMIT_MESSAGE>` with their literal values, then run the following bash block. Stop immediately and report any failure. | ||
|
|
||
| ```bash | ||
| REPO="<REPO>" | ||
| TREE_SHA="<TREE_SHA>" | ||
| PARENT_SHA="<PARENT_SHA>" | ||
| COMMIT_MESSAGE="<COMMIT_MESSAGE>" | ||
|
|
||
| # Read committer identity from local git config. | ||
| # GPG_KEY prefers an explicit signingkey; falls back to user.email as the key identifier. | ||
| AUTHOR_NAME=$(git config user.name | tr -d '\n') | ||
| AUTHOR_EMAIL=$(git config user.email | tr -d '\n') | ||
| GPG_KEY=$(git config user.signingkey 2>/dev/null | tr -d '\n') | ||
| GPG_KEY="${GPG_KEY:-$AUTHOR_EMAIL}" | ||
|
|
||
| # Allocate temp files with random names via mktemp. | ||
| # Fixed names are vulnerable to symlink attacks: a process running as the same | ||
| # user could pre-create the name as a symlink pointing elsewhere, causing writes | ||
| # to land on an unintended target. mktemp creates a file with an unpredictable | ||
| # suffix, closing that window. | ||
| # NOTE: on macOS, mktemp requires the template to end with XXXXXX — no suffix | ||
| # (e.g. .json) is allowed after the X's or macOS uses the literal name instead | ||
| # of randomising it. | ||
| COMMIT_PAYLOAD=$(mktemp /tmp/git-signed-commit-payload-XXXXXX) | ||
| COMMIT_SIG=$(mktemp /tmp/git-signed-commit-sig-XXXXXX) | ||
|
|
||
| # Register a trap that fires on normal exit (EXIT), Ctrl-C (INT), and external | ||
| # kill signals (TERM). Removes temp files unconditionally. | ||
| trap 'rm -f "$COMMIT_PAYLOAD" "$COMMIT_SIG"' EXIT INT TERM | ||
|
|
||
| # 1. [LOCAL] Build the raw git commit object text, then sign it with GPG. | ||
| # | ||
| # GitHub verifies a signed commit by reconstructing the commit object from | ||
| # the fields we pass to the API and checking the signature against it. | ||
| # For verification to succeed, the text we sign here must be byte-for-byte | ||
| # identical to what GitHub constructs. | ||
| # | ||
| # The git commit object format is: | ||
| # tree <tree-sha> | ||
| # parent <parent-sha> | ||
| # author Name <email> <unix-epoch> <tz-offset> | ||
| # committer Name <email> <unix-epoch> <tz-offset> | ||
| # (blank line) | ||
| # <commit message> | ||
| # | ||
| # We use UTC (+0000) for the timezone and derive the ISO-8601 date passed | ||
| # to the API from the same epoch value, so both representations refer to | ||
| # the exact same point in time with no rounding risk. | ||
| UNIX_TS=$(date -u +%s) | ||
| DATE_ISO=$(date -u -r "$UNIX_TS" +"%Y-%m-%dT%H:%M:%SZ") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
|
|
||
| COMMIT_OBJECT=$(printf 'tree %s\nparent %s\nauthor %s <%s> %d +0000\ncommitter %s <%s> %d +0000\n\n%s\n\nSigned-off-by: %s <%s>\n' \ | ||
| "$TREE_SHA" \ | ||
| "$PARENT_SHA" \ | ||
| "$AUTHOR_NAME" "$AUTHOR_EMAIL" "$UNIX_TS" \ | ||
| "$AUTHOR_NAME" "$AUTHOR_EMAIL" "$UNIX_TS" \ | ||
| "$COMMIT_MESSAGE" \ | ||
| "$AUTHOR_NAME" "$AUTHOR_EMAIL") | ||
|
|
||
| # Produce a detached armored PGP signature of the commit object text. | ||
| # --detach-sign: signs without embedding the data (GitHub only wants the signature). | ||
| # --armor: ASCII-armored output (the -----BEGIN PGP SIGNATURE----- block). | ||
| # --local-user: selects the key by ID or email; matches git's own signing behaviour. | ||
| # --no-tty: do not use the terminal for input, allowing pinentry-mac (GUI) to | ||
| # show a passphrase dialog window if the key is not already unlocked in the agent. | ||
| # --yes: allow GPG to overwrite the output file. mktemp pre-creates the file | ||
| # as an empty placeholder; without --yes, GPG refuses to write to it. | ||
| # stderr is captured (not suppressed) so we can report the actual GPG error if signing fails. | ||
| GPG_STDERR=$(printf '%s' "$COMMIT_OBJECT" | \ | ||
| gpg --no-tty --yes \ | ||
| --detach-sign --armor --local-user "$GPG_KEY" --output "$COMMIT_SIG" 2>&1) | ||
|
|
||
| if [ ! -s "$COMMIT_SIG" ]; then | ||
| echo "ERROR: GPG signing failed — ensure key '$GPG_KEY' is available (gpg --list-secret-keys)" | ||
| echo "GPG output: $GPG_STDERR" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # 2. [WRITE] Create the commit object in the remote repo via the Git Data API. | ||
| # The API accepts the same fields as the commit object text plus the detached | ||
| # PGP signature. GitHub reconstructs the object, verifies the signature against | ||
| # the registered public key on the account, and marks the commit as Verified. | ||
| # Python constructs the JSON so the multi-line PGP signature is properly escaped. | ||
| export _TREE="$TREE_SHA" _PARENT="$PARENT_SHA" | ||
| export _ANAME="$AUTHOR_NAME" _AEMAIL="$AUTHOR_EMAIL" _DATE="$DATE_ISO" | ||
| export _COMMIT_SIG="$COMMIT_SIG" _MSG="$COMMIT_MESSAGE" | ||
|
|
||
| python3 -c " | ||
| import json, os | ||
| sig = open(os.environ['_COMMIT_SIG']).read() | ||
| msg = os.environ['_MSG'] + '\n\nSigned-off-by: ' + os.environ['_ANAME'] + ' <' + os.environ['_AEMAIL'] + '>' | ||
| print(json.dumps({ | ||
| 'message': msg, | ||
| 'tree': os.environ['_TREE'], | ||
| 'parents': [os.environ['_PARENT']], | ||
| 'author': {'name': os.environ['_ANAME'], 'email': os.environ['_AEMAIL'], 'date': os.environ['_DATE']}, | ||
| 'committer': {'name': os.environ['_ANAME'], 'email': os.environ['_AEMAIL'], 'date': os.environ['_DATE']}, | ||
| 'signature': sig, | ||
| })) | ||
| " > "$COMMIT_PAYLOAD" | ||
|
|
||
| # Unset exported env vars now that the payload file has been written. | ||
| unset _TREE _PARENT _ANAME _AEMAIL _DATE _COMMIT_SIG _MSG | ||
|
|
||
| COMMIT_SHA=$(gh api "repos/$REPO/git/commits" --input "$COMMIT_PAYLOAD" --jq '.sha') | ||
| [ -z "$COMMIT_SHA" ] && { echo "ERROR: commit creation failed"; exit 1; } | ||
|
|
||
| # 3. [READ] Check that GitHub was able to verify the GPG signature against the | ||
| # public key registered on the account. A successful commit creation does not | ||
| # imply verification — if the key is not registered on GitHub, the commit is | ||
| # accepted but marked Unverified, which defeats the purpose of signing it. | ||
| # Both fields are fetched in a single API call using @tsv to avoid a second | ||
| # round-trip on the failure path. | ||
| VERIFY=$(gh api "repos/$REPO/git/commits/$COMMIT_SHA" \ | ||
| --jq '[.verification.verified, .verification.reason] | @tsv') | ||
| VERIFIED=$(echo "$VERIFY" | cut -f1) | ||
| VERIFY_REASON=$(echo "$VERIFY" | cut -f2) | ||
| if [ "$VERIFIED" != "true" ]; then | ||
| echo "WARNING: commit created but GitHub could not verify the signature (reason: $VERIFY_REASON)" | ||
| echo "Ensure the GPG public key for '$GPG_KEY' is registered at https://github.com/settings/keys" | ||
| fi | ||
|
|
||
| echo "COMMIT_SHA=$COMMIT_SHA" | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Output on success | ||
|
|
||
| The final line of output is: | ||
|
|
||
| ``` | ||
| COMMIT_SHA=<sha> | ||
| ``` | ||
|
|
||
| Read this line to obtain the commit SHA for further operations (e.g. advancing a branch ref). | ||
Oops, something went wrong.
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.
What happens if an XML file is modified in a
fix/ortechnical/branch? Shouldn't this apply to all branches, not justfeature/?