Skip to content

Commit 2581181

Browse files
πŸ› fix(token): change gh token for inputs (#3)
## πŸ’Œ Description <!-- Add a more detailed description of the changes if needed. --> ## πŸ”— Related issue <!-- If your PR refers to a related issue, link it here. --> Fixes: # ## πŸ—οΈ Type of change <!-- Mark with an `x` all the checkboxes that apply (like `[x]`) --> - [ ] πŸ“š Examples / docs / tutorials - [ ] πŸ› Bug fix (non-breaking change which fixes an issue) - [ ] πŸ₯‚ Improvement (non-breaking change which improves an existing feature) - [ ] πŸš€ New feature (non-breaking change which adds functionality) - [ ] πŸ’₯ Breaking change (fix or feature that would cause existing functionality to change) - [ ] 🚨 Security fix - [ ] ⬆️ Dependencies update ## βœ… Checklist <!-- Mark with an `x` all the checkboxes that apply (like `[x]`) --> - [ ] I've read the [`Code of Conduct`](https://github.com/raven-actions/get-repos/blob/main/.github/CODE_OF_CONDUCT.md)> document. - [ ] I've read the [`Contributing`](https://github.com/raven-actions/get-repos/blob/main/.github/CONTRIBUTING.md) guide.
1 parent 6954705 commit 2581181

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

β€Ž.github/workflows/ci.ymlβ€Ž

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,26 @@ jobs:
5252
- name: Checkout
5353
uses: actions/checkout@v3
5454

55+
- name: Get GitHub Token
56+
uses: wow-actions/use-app-token@v2
57+
id: get-token
58+
with:
59+
app_id: ${{ secrets.ORG_BOT_APP_ID }}
60+
private_key: ${{ secrets.ORG_BOT_PRIVATE_KEY }}
61+
fallback: ${{ github.token }}
62+
5563
- name: Get Repositories Action (json)
5664
id: get-repos
5765
uses: ./
5866
with:
67+
github-token: ${{ steps.get-token.outputs.BOT_TOKEN }}
5968
topics: "raven-actions,composite-action"
6069

6170
- name: Get Repositories Action (flat)
6271
id: get-repos-flat
6372
uses: ./
6473
with:
74+
github-token: ${{ steps.get-token.outputs.BOT_TOKEN }}
6575
topics: "raven-actions,composite-action,debug"
6676
format: flat
6777

@@ -114,10 +124,19 @@ jobs:
114124
- name: Checkout
115125
uses: actions/checkout@v3
116126

127+
- name: Get GitHub Token
128+
uses: wow-actions/use-app-token@v2
129+
id: get-token
130+
with:
131+
app_id: ${{ secrets.ORG_BOT_APP_ID }}
132+
private_key: ${{ secrets.ORG_BOT_PRIVATE_KEY }}
133+
fallback: ${{ github.token }}
134+
117135
- name: Get Repositories Action
118136
id: get-repos
119137
uses: ./
120138
with:
139+
github-token: ${{ steps.get-token.outputs.BOT_TOKEN }}
121140
topics: "github-actions,actions"
122141
operator: AND
123142

β€ŽREADME.mdβ€Ž

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ You can also use this action to get a **flat** output with your delimiter for di
2929

3030
### Quick Start
3131

32-
Example GitHub Workflow, to get all repositories that contain **ALL** listed topics (`AND` operator is by default). Follow [πŸ“₯ Inputs](#-inputs) to adjust behavior to `OR`. Then the result will be: get all repos with **ANY** listed topics.
32+
Example GitHub Workflow, to get all repositories that contain **ANY** of listed topics (`OR` operator is by default). Follow [πŸ“₯ Inputs](#-inputs) to adjust behavior to `AND`. Then the result will be: get all repos with **ALL** listed topics.
3333

3434
```yaml
3535
name: Sync Repositories
@@ -50,7 +50,6 @@ jobs:
5050
uses: raven-actions/get-repos@v1
5151
with:
5252
topics: "sync,docs,managed"
53-
operator: OR # logic operator for topics match, OR returns repos that have any of provided topics
5453

5554
sync-repos:
5655
name: Sync (${{ matrix.repo.name }})
@@ -79,7 +78,7 @@ jobs:
7978
uses: raven-actions/get-repos@v1
8079
with:
8180
topics: "raven-actions,composite-action"
82-
operator: AND # logic operator for topics match, AND returns repos that have all of provided topics, AND is default
81+
operator: AND # logic operator for topics match, AND returns repos that have all of provided topics, OR is default
8382
format: flat
8483
delimiter: "," # default one is '\n'
8584

@@ -101,7 +100,7 @@ jobs:
101100
|:--------------:|:--------:|:--------:|:-------------------------:|-----------------------------------------------------------------------------------------------------|
102101
| `owner` | false | `string` | `github.repository_owner` | The organization or user name |
103102
| `topics` | false | `string` | _not set_ | Comma-separated list of repository topics |
104-
| `operator` | false | `string` | `AND` | Logic operator to use when filtering repositories by topics, `OR` or `AND` |
103+
| `operator` | false | `string` | `OR` | Logic operator to use when filtering repositories by topics, `OR` or `AND` |
105104
| `matrix-use` | false | `bool` | `true` | Output to be used in matrix job? It just checks that the returned query has not exceeded 256 repos |
106105
| `format` | false | `string` | `json` | Output format, `json` or `flat`, default to `json` |
107106
| `delimiter` | false | `string` | `\n` | Delimiter to use when `format` is `flat`, default to `\n` |

β€Žaction.ymlβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ inputs:
1616
description: Comma-separated list of repository topics
1717
required: false
1818
operator:
19-
description: Operator to use when filtering repositories by topics, `OR` or `AND`, default to `AND`
19+
description: Operator to use when filtering repositories by topics, `OR` or `AND`, default to `OR`
2020
required: false
21-
default: AND
21+
default: OR
2222
matrix-use:
2323
description: Output to use in the matrix job?, `true` or `false`
2424
required: false
@@ -52,12 +52,13 @@ runs:
5252
- uses: actions/github-script@v6
5353
id: repos
5454
with:
55+
github-token: ${{ inputs.github-token || env.GITHUB_TOKEN }}
5556
script: |
5657
// constraints
5758
const choiceBool = ['true', 'false']
5859
5960
// inputs
60-
const { INPUT_OWNER, INPUT_TOPICS, INPUT_OPERATOR, INPUT_MATRIX_USE, INPUT_OUTPUT_FORMAT, INPUT_FLAT_DELIMITER} = process.env
61+
const { INPUT_OWNER, INPUT_TOPICS, INPUT_OPERATOR, INPUT_MATRIX_USE, INPUT_OUTPUT_FORMAT, INPUT_FLAT_DELIMITER } = process.env
6162
6263
// owner
6364
let inputOwner = ''
@@ -79,7 +80,7 @@ runs:
7980
}).flat().filter(element => element !== '') : []
8081
8182
// operator
82-
const inputOperator = INPUT_OPERATOR ? INPUT_OPERATOR.trim().toUpperCase() : 'AND'
83+
const inputOperator = INPUT_OPERATOR ? INPUT_OPERATOR.trim().toUpperCase() : 'OR'
8384
const choiceInputOperator = ['AND', 'OR']
8485
if (!choiceInputOperator.includes(inputOperator)) {
8586
core.setFailed(`Invalid operator: ${inputOperator}, accepted values: ${choiceInputOperator.join(', ')}`)
@@ -183,10 +184,9 @@ runs:
183184
core.setOutput('repos', repos)
184185
core.setOutput('format', inputOutputFormat)
185186
env:
186-
GITHUB_TOKEN: ${{ inputs.github-token || env.GITHUB_TOKEN }}
187187
INPUT_OWNER: ${{ inputs.owner }}
188188
INPUT_TOPICS: ${{ inputs.topics }}
189-
INPUT_OPERATOR: ${{ inputs.operator || 'AND' }}
189+
INPUT_OPERATOR: ${{ inputs.operator || 'OR' }}
190190
INPUT_MATRIX_USE: ${{ inputs.matrix-use || true }}
191191
INPUT_OUTPUT_FORMAT: ${{ inputs.format || 'json' }}
192192
INPUT_FLAT_DELIMITER: ${{ inputs.delimiter }}

0 commit comments

Comments
Β (0)