Skip to content

Commit d2cdb75

Browse files
authored
docs(README): create tokens for multiple accounts (actions#63)
Adds an example workflow to the README that shows how a matrix strategy can be used to create tokens for multiple user or organization accounts. Resolves actions#45.
1 parent 3bb715c commit d2cdb75

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

Diff for: README.md

+46
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,52 @@ jobs:
124124
body: "Hello, World!"
125125
```
126126

127+
### Create tokens for multiple user or organization accounts
128+
129+
You can use a matrix strategy to create tokens for multiple user or organization accounts.
130+
131+
> [!NOTE]
132+
> See [this documentation](https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings) for information on using multiline strings in workflows.
133+
134+
```yaml
135+
on: [workflow_dispatch]
136+
137+
jobs:
138+
set-matrix:
139+
runs-on: ubuntu-latest
140+
outputs:
141+
matrix: ${{steps.set.outputs.matrix }}
142+
steps:
143+
- id: set
144+
run: echo 'matrix=[{"owner":"owner1"},{"owner":"owner2","repos":["repo1"]}]' >>"$GITHUB_OUTPUT"
145+
146+
use-matrix:
147+
name: '@${{ matrix.owners-and-repos.owner }} installation'
148+
needs: [set-matrix]
149+
runs-on: ubuntu-latest
150+
strategy:
151+
matrix:
152+
owners-and-repos: ${{ fromJson(needs.set-matrix.outputs.matrix) }}
153+
154+
steps:
155+
- uses: actions/create-github-app-token@v1
156+
id: app-token
157+
with:
158+
app_id: ${{ vars.APP_ID }}
159+
private_key: ${{ secrets.PRIVATE_KEY }}
160+
owner: ${{ matrix.owners-and-repos.owner }}
161+
repositories: ${{ join(matrix.owners-and-repos.repos) }}
162+
- uses: octokit/[email protected]
163+
id: get-installation-repositories
164+
with:
165+
route: GET /installation/repositories
166+
env:
167+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
168+
- run: echo "$MULTILINE_JSON_STRING"
169+
env:
170+
MULTILINE_JSON_STRING: ${{ steps.get-installation-repositories.outputs.data }}
171+
```
172+
127173
## Inputs
128174

129175
### `app-id`

0 commit comments

Comments
 (0)