You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+86-5Lines changed: 86 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,14 @@ Offered as node module and CLI tool.
14
14
15
15
- Automate the process of committing file additions, changes, or deletions to a GitHub repository without cloning it locally
16
16
- Integrate with existing CI/CD pipelines perform signed commits on behalf of the pipeline, without hard-to-setup GPG config
17
-
- Avoid storing private SSH keys in CI/CD environments (only the GITHUB_TOKEN is needed and can be easily saved as secret string passed as environment variable at pipeline runtime)
17
+
- Avoid storing private SSH keys in CI/CD environments (only the `GITHUB_TOKEN` is needed and can be easily saved as secret string passed as environment variable at pipeline runtime)
18
18
- you name it...
19
19
20
+
I have actually written this to get signed commits in GitHub Actions running [here](https://github.com/pirafrank/fpiracom).
21
+
20
22
## ⚠️ Before you start
21
23
24
+
-`GITHUB_TOKEN` must be set as environment variable. It must have write access to the repository you want to commit to
22
25
- Changed (or new) files must exist locally
23
26
- for practial reasons, those files must have the same file name and file path as the ones in the repository you are replacing with your commit (or the same file name and file path you want them to have in the repository)
24
27
- Deleted files may not exist locally, and their path may just be provided as argument
@@ -38,7 +41,9 @@ Note: in GitHub Actions the `GITHUB_TOKEN` is automatically generated per each r
38
41
npm install
39
42
```
40
43
41
-
## Usage examples
44
+
## CLI
45
+
46
+
### Usage examples
42
47
43
48
```sh
44
49
export GITHUB_TOKEN='your_github_token_here'
@@ -60,21 +65,97 @@ node github.js commit \
60
65
--commitMessage 'remove .gitignore'
61
66
```
62
67
68
+
Multi-file commit is also possible:
69
+
70
+
-`--changed` and `--deleted` may have multiple file paths, as a single string with space-separated values, or by repeating the option per each file path. All file paths must be relative to the repository root.
If called without arguments, it will use the `GITHUB_TOKEN` and `GITHUB_GRAPHQL_URL` environment variables.
101
+
102
+
```js
103
+
init();
104
+
```
105
+
106
+
Please refer to `index.js` for the function signatures.
107
+
108
+
## GitHub Action usage
109
+
110
+
You can use this module as a GitHub Action. It is a Docker-based action.
111
+
112
+
### Print help
113
+
114
+
```yaml
115
+
# Print help
116
+
- name: Print graphQL client help
117
+
uses: pirafrank/github-graphql-client@v1
118
+
with:
119
+
args: "--help"
120
+
```
121
+
122
+
### Commit changes
123
+
124
+
Requirements when running in a GitHub Actions workflow:
125
+
126
+
- `--changed` and `--deleted` may have multiple file paths, as a single string with space-separated values, or by repeating the option per each file path. All file paths must be relative to the repository root.
127
+
- `GITHUB_TOKEN`must be set in the environment variables with write access to the repository. Go to *Repository Settings > Actions > General > Workflow permissions*, and set `Read and write permissions`.
128
+
129
+
To commit to other repositories, you may need to override the default `GITHUB_TOKEN` with a personal access token with the `repo` scope. Go to *Profile > Settings > Developer settings > Personal access tokens > Token (classic)*, and Generate new token (classic) with the full-control over `repo` scope. Tip: store the generated token in repository secrets.
130
+
131
+
```yaml
132
+
# Commit changes...
133
+
- name: Commit changes
134
+
id: commit_changes
135
+
uses: pirafrank/github-graphql-client@v1
136
+
if: ${{ vars.RUN_COMMIT_CHANGES == 'true' }}
137
+
env:
138
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139
+
with:
140
+
args: "commit --owner=${{ github.repository_owner }} --repo=${{ github.event.repository.name }} --branch=${{ github.ref_name }} --commitMessage='this is a webflow signed commit' --changed new.txt dummy/subdir/changed.txt --deleted dummy/delete_me.txt another_deleted.txt"
0 commit comments