@@ -13,28 +13,60 @@ GitHub on behalf of the application.
1313
1414## Usage
1515
16- Currently, there is one command: ` commit-headless push ` . It takes a target owner/repository and
17- remote branch name, as well as a list of commit hashes as arguments * or* a list of commit hashes * in
18- reverse chronological order (newest first)* on standard input.
16+ There are two ways to create signed headless commits with this tool: ` push ` and ` commit ` .
17+
18+ Both of these commands take a target owner/repository (eg, ` --target/-T DataDog/commit-headless ` )
19+ and remote branch name (eg, ` --branch bot-branch ` ) as required flags and expect to find a GitHub
20+ token in one of the following environment variables:
21+
22+ - HEADLESS_TOKEN
23+ - GITHUB_TOKEN
24+ - GH_TOKEN
25+
26+ In normal usage, ` commit-headless ` will print * only* the reference to the last commit created on the
27+ remote, allowing this to easily be captured in a script.
28+
29+ More on the specifics for each command below. See also: ` commit-headless <command> --help `
30+
31+ ### commit-headless push
32+
33+ In addition to the required target and branch flags, the ` push ` command expects a list of commit
34+ hashes as arguments * or* a list of commit hashes * in reverse chronological order (newest first)*
35+ on standard input.
1936
2037It will iterate over the supplied commits, extract the set of changed files and commit message, then
2138craft new * remote* commits corresponding to each local commit.
2239
2340The remote commit will have the original commit message, with "Co-authored-by" trailer for the
24- original commit message. This is because commits created using the GraphQL API do not support
25- setting the author or committer (they are inferred from the token owner), so adding a
26- "Co-authored-by" trailer allows the commits to carry attribution to the original (bot) committer.
27-
28- In normal usage, ` commit-headless ` will print * only* the reference to the last commit created on the
29- remote, allowing this to easily be captured in a script. For example output, see the later section.
41+ original commit author.
3042
3143You can use ` commit-headless push ` via:
3244
33- GH_TOKEN=xyz commit-headless push --target datadog/commit-headless --branch bot-branch-remote HASH1 HASH2 HASH3 ...
45+ commit-headless push [flags...] HASH1 HASH2 HASH3 ...
3446
3547Or, using git log (note ` --oneline ` ):
3648
37- git log --oneline main.. | GH_TOKEN=xyz commit-headless push --target datadog/commit-headless --branch bot-branch-remote
49+ git log --oneline main.. | commit-headless push [flags...]
50+
51+ ### commit-headless commit
52+
53+ This command is more geared for creating single commits at a time. It takes a list of files to
54+ commit changes to, and those files will either be updated/added or deleted in a single commit.
55+
56+ Note that you cannot delete a file without also adding ` --force ` for safety reasons.
57+
58+ Examples:
59+
60+ # Commit changes to these two files
61+ commit-headless commit [flags...] -- README.md .gitlab-ci.yml
62+
63+ # Remove a file, add another one, and commit
64+ rm file/i/do/not/want
65+ echo "hello" > hi-there.txt
66+ commit-headless commit [flags...] --force -- hi-there.txt file/i/do/not/want
67+
68+ # Commit a change with a custom message
69+ commit-headless commit [flags...] -m"ran a pipeline" -- output.txt
3870
3971## Try it!
4072
@@ -88,13 +120,14 @@ Prerelease occurs automatically on a push to main, or can be manually triggered
88120` release:build ` job on any branch.
89121
90122Additionally, on main, the ` release:publish ` job will run. This job takes the prerelease image and
91- tags it for release.
123+ tags it for release, as well as produces a CI image with various other tools .
92124
93125You can view all releases (and prereleases) with crane:
94126
95127```
96128$ crane ls registry.ddbuild.io/commit-headless-prerelease
97129$ crane ls registry.ddbuild.io/commit-headless
130+ $ crane ls registry.ddbuild.io/commit-headless-ci-image
98131```
99132
100133Note that the final publish job will fail unless there was also a change to ` version.go ` to avoid
0 commit comments