@@ -18,6 +18,21 @@ Or install it yourself as:
1818
1919 $ gem install rake_github
2020
21+ ### System dependencies
22+
23+ The ` secrets ` task group encrypts secrets client-side using ` rbnacl ` , which
24+ requires the native [ libsodium] ( https://libsodium.org ) library to be present on
25+ the host. Install it before running any ` secrets ` task:
26+
27+ # macOS
28+ $ brew install libsodium
29+
30+ # Debian/Ubuntu
31+ $ apt-get install libsodium23
32+
33+ libsodium is only required when using the ` secrets ` tasks; the other task groups
34+ have no additional system dependencies.
35+
2136## Usage
2237
2338### define_deploy_keys_tasks
5267| deploy_keys_destroy_task_name | symbol | N | Option to change the destroy task name | : obliterate | : destroy |
5368| deploy_keys_provision_task_name | symbol | N | Option to change the provision task name | : add | : provision |
5469| deploy_keys_ensure_task_name | symbol | N | Option to change the ensure task name | : destroy_and_provision | : ensure |
70+ | secrets | array | N | Secrets to provision on the repository | { name: string, value: string, dependabot: bool } | [ ] |
71+ | secrets_namespace | symbol | N | Namespace to contain secrets tasks | : repository_secrets | : secrets |
72+ | secrets_destroy_task_name | symbol | N | Option to change the secrets destroy task name | : obliterate | : destroy |
73+ | secrets_provision_task_name | symbol | N | Option to change the secrets provision task name | : add | : provision |
74+ | secrets_ensure_task_name | symbol | N | Option to change the secrets ensure task name | : destroy_and_provision | : ensure |
75+ | environments | array | N | Environments to provision on the repository | { name: string, reviewers: array } | [ ] |
76+ | environments_namespace | symbol | N | Namespace to contain environments tasks | : repository_environments | : environments |
77+ | environments_destroy_task_name | symbol | N | Option to change the environments destroy task name | : obliterate | : destroy |
78+ | environments_provision_task_name| symbol | N | Option to change the environments provision task name | : add | : provision |
79+ | environments_ensure_task_name | symbol | N | Option to change the environments ensure task name | : destroy_and_provision | : ensure |
5580| namespace | symbol | N | Namespace for tasks to live in, defaults to root namespace | : rake_github | N/A |
5681
5782Exposes tasks:
@@ -62,6 +87,12 @@ $ rake -T
6287rake github:deploy_keys:destroy
6388rake github:deploy_keys:ensure
6489rake github:deploy_keys:provision
90+ rake github:secrets:destroy
91+ rake github:secrets:ensure
92+ rake github:secrets:provision
93+ rake github:environments:destroy
94+ rake github:environments:ensure
95+ rake github:environments:provision
6596rake github:pull_requests:merge[branch_name,commit_message]
6697```
6798
@@ -84,6 +115,145 @@ Merges the PR associated with the `branch_name`. Branch name is required.
84115` commit_message ` is optional, and can contain the original commit message with
85116the ` %s ` placeholder, e.g. ` pull_requests:merge[new_feature,"%s [skip ci]"] ` .
86117
118+ ### define_secrets_tasks
119+
120+ Sets up rake tasks for managing repository secrets. Each secret is written to
121+ the Actions secret store by default. A secret can additionally be written to the
122+ Dependabot secret store by setting ` dependabot: true ` , so that
123+ Dependabot-triggered workflow runs can read the secrets they need. Secrets are
124+ encrypted client-side before being sent to GitHub.
125+
126+ These tasks require the native libsodium library to be installed on the host —
127+ see [ System dependencies] ( #system-dependencies ) above.
128+
129+ ``` ruby
130+ require ' rake_github'
131+
132+ RakeGithub .define_secrets_tasks(
133+ namespace: :secrets ,
134+ repository: ' org/repo' , # required
135+ ) do |t |
136+ t.access_token = " your_github_access_token" # required
137+ t.secrets = [
138+ {
139+ name: ' SOME_SECRET' ,
140+ value: ' some-plaintext-value'
141+ },
142+ {
143+ name: ' SHARED_SECRET' ,
144+ value: ' another-plaintext-value' ,
145+ dependabot: true # also write to the Dependabot store
146+ }
147+ ]
148+ end
149+ ```
150+
151+ | Parameter | Type | Required | Description | Example | Default |
152+ | ----------------------| --------| ----------| ------------------------------------------------------------| ---------------------------------------------| ------------|
153+ | repository | string | Y | Repository to perform tasks upon | 'organisation/repository_name' | N/A |
154+ | access_token | string | Y | Github token for authorisation | 'ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | N/A |
155+ | secrets | array | N | Secrets to provision on the repository | { name: string, value: string, dependabot: bool } | [ ] |
156+ | destroy_task_name | symbol | N | Option to change the destroy task name | : obliterate | : destroy |
157+ | provision_task_name | symbol | N | Option to change the provision task name | : add | : provision |
158+ | ensure_task_name | symbol | N | Option to change the ensure task name | : destroy_and_provision | : ensure |
159+ | namespace | symbol | N | Namespace for tasks to live in, defaults to root namespace | : secrets | N/A |
160+
161+ Exposes tasks:
162+
163+ ``` shell
164+ $ rake -T
165+
166+ rake secrets:destroy
167+ rake secrets:ensure
168+ rake secrets:provision
169+ ```
170+
171+ #### secrets: provision
172+
173+ Provisions the specified secrets to the repository, writing each one to the
174+ Actions secret store and, for secrets marked ` dependabot: true ` , also to the
175+ Dependabot secret store.
176+
177+ #### secrets: destroy
178+
179+ Destroys the specified secrets from the repository, removing each one from both
180+ the Actions and Dependabot secret stores.
181+
182+ #### secrets: ensure
183+
184+ Destroys and then provisions the specified secrets on the repository.
185+
186+ ### define_environments_tasks
187+
188+ Sets up rake tasks for managing GitHub deployment environments, including
189+ protection rules such as required reviewers. Team and user reviewers are
190+ resolved to their numeric ids before being sent to GitHub.
191+
192+ ``` ruby
193+ require ' rake_github'
194+
195+ RakeGithub .define_environments_tasks(
196+ namespace: :environments ,
197+ repository: ' org/repo' , # required
198+ ) do |t |
199+ t.access_token = " your_github_access_token" # required
200+ t.environments = [
201+ {
202+ name: ' release' ,
203+ wait_timer: 0 ,
204+ prevent_self_review: false ,
205+ reviewers: [
206+ { team: ' maintainers' },
207+ { user: ' someone' }
208+ ],
209+ deployment_branch_policy: {
210+ protected_branches: true ,
211+ custom_branch_policies: false
212+ }
213+ }
214+ ]
215+ end
216+ ```
217+
218+ Only ` name ` is required for each environment; every other key is optional and
219+ is omitted from the GitHub API payload when absent.
220+
221+ | Parameter | Type | Required | Description | Example | Default |
222+ | ----------------------| --------| ----------| ------------------------------------------------------------| ---------------------------------------------| ----------------|
223+ | repository | string | Y | Repository to perform tasks upon | 'organisation/repository_name' | N/A |
224+ | access_token | string | Y | Github token for authorisation | 'ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | N/A |
225+ | environments | array | N | Environments to provision on the repository | { name: string, reviewers: array } | [ ] |
226+ | destroy_task_name | symbol | N | Option to change the destroy task name | : obliterate | : destroy |
227+ | provision_task_name | symbol | N | Option to change the provision task name | : add | : provision |
228+ | ensure_task_name | symbol | N | Option to change the ensure task name | : destroy_and_provision | : ensure |
229+ | namespace | symbol | N | Namespace for tasks to live in, defaults to root namespace | : environments | N/A |
230+
231+ Exposes tasks:
232+
233+ ``` shell
234+ $ rake -T
235+
236+ rake environments:destroy
237+ rake environments:ensure
238+ rake environments:provision
239+ ```
240+
241+ #### environments: provision
242+
243+ Provisions the specified environments on the repository, resolving any team
244+ and user reviewers to their numeric ids.
245+
246+ #### environments: destroy
247+
248+ Destroys the specified environments from the repository. This is irreversible
249+ and also discards each environment's protection rules, environment secrets and
250+ deployment history. ` environments:ensure ` therefore fully recreates each
251+ environment rather than patching it in place.
252+
253+ #### environments: ensure
254+
255+ Destroys and then provisions the specified environments on the repository.
256+
87257### define_release_task
88258
89259## Development
0 commit comments