Skip to content

Commit

Permalink
πŸ› fix(token): change gh token for inputs (#3)
Browse files Browse the repository at this point in the history
## πŸ’Œ 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.
  • Loading branch information
DariuszPorowski authored May 11, 2023
1 parent 6954705 commit 2581181
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,26 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Get GitHub Token
uses: wow-actions/use-app-token@v2
id: get-token
with:
app_id: ${{ secrets.ORG_BOT_APP_ID }}
private_key: ${{ secrets.ORG_BOT_PRIVATE_KEY }}
fallback: ${{ github.token }}

- name: Get Repositories Action (json)
id: get-repos
uses: ./
with:
github-token: ${{ steps.get-token.outputs.BOT_TOKEN }}
topics: "raven-actions,composite-action"

- name: Get Repositories Action (flat)
id: get-repos-flat
uses: ./
with:
github-token: ${{ steps.get-token.outputs.BOT_TOKEN }}
topics: "raven-actions,composite-action,debug"
format: flat

Expand Down Expand Up @@ -114,10 +124,19 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Get GitHub Token
uses: wow-actions/use-app-token@v2
id: get-token
with:
app_id: ${{ secrets.ORG_BOT_APP_ID }}
private_key: ${{ secrets.ORG_BOT_PRIVATE_KEY }}
fallback: ${{ github.token }}

- name: Get Repositories Action
id: get-repos
uses: ./
with:
github-token: ${{ steps.get-token.outputs.BOT_TOKEN }}
topics: "github-actions,actions"
operator: AND

Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ You can also use this action to get a **flat** output with your delimiter for di

### Quick Start

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.
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.

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

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

Expand All @@ -101,7 +100,7 @@ jobs:
|:--------------:|:--------:|:--------:|:-------------------------:|-----------------------------------------------------------------------------------------------------|
| `owner` | false | `string` | `github.repository_owner` | The organization or user name |
| `topics` | false | `string` | _not set_ | Comma-separated list of repository topics |
| `operator` | false | `string` | `AND` | Logic operator to use when filtering repositories by topics, `OR` or `AND` |
| `operator` | false | `string` | `OR` | Logic operator to use when filtering repositories by topics, `OR` or `AND` |
| `matrix-use` | false | `bool` | `true` | Output to be used in matrix job? It just checks that the returned query has not exceeded 256 repos |
| `format` | false | `string` | `json` | Output format, `json` or `flat`, default to `json` |
| `delimiter` | false | `string` | `\n` | Delimiter to use when `format` is `flat`, default to `\n` |
Expand Down
12 changes: 6 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ inputs:
description: Comma-separated list of repository topics
required: false
operator:
description: Operator to use when filtering repositories by topics, `OR` or `AND`, default to `AND`
description: Operator to use when filtering repositories by topics, `OR` or `AND`, default to `OR`
required: false
default: AND
default: OR
matrix-use:
description: Output to use in the matrix job?, `true` or `false`
required: false
Expand Down Expand Up @@ -52,12 +52,13 @@ runs:
- uses: actions/github-script@v6
id: repos
with:
github-token: ${{ inputs.github-token || env.GITHUB_TOKEN }}
script: |
// constraints
const choiceBool = ['true', 'false']
// inputs
const { INPUT_OWNER, INPUT_TOPICS, INPUT_OPERATOR, INPUT_MATRIX_USE, INPUT_OUTPUT_FORMAT, INPUT_FLAT_DELIMITER} = process.env
const { INPUT_OWNER, INPUT_TOPICS, INPUT_OPERATOR, INPUT_MATRIX_USE, INPUT_OUTPUT_FORMAT, INPUT_FLAT_DELIMITER } = process.env
// owner
let inputOwner = ''
Expand All @@ -79,7 +80,7 @@ runs:
}).flat().filter(element => element !== '') : []
// operator
const inputOperator = INPUT_OPERATOR ? INPUT_OPERATOR.trim().toUpperCase() : 'AND'
const inputOperator = INPUT_OPERATOR ? INPUT_OPERATOR.trim().toUpperCase() : 'OR'
const choiceInputOperator = ['AND', 'OR']
if (!choiceInputOperator.includes(inputOperator)) {
core.setFailed(`Invalid operator: ${inputOperator}, accepted values: ${choiceInputOperator.join(', ')}`)
Expand Down Expand Up @@ -183,10 +184,9 @@ runs:
core.setOutput('repos', repos)
core.setOutput('format', inputOutputFormat)
env:
GITHUB_TOKEN: ${{ inputs.github-token || env.GITHUB_TOKEN }}
INPUT_OWNER: ${{ inputs.owner }}
INPUT_TOPICS: ${{ inputs.topics }}
INPUT_OPERATOR: ${{ inputs.operator || 'AND' }}
INPUT_OPERATOR: ${{ inputs.operator || 'OR' }}
INPUT_MATRIX_USE: ${{ inputs.matrix-use || true }}
INPUT_OUTPUT_FORMAT: ${{ inputs.format || 'json' }}
INPUT_FLAT_DELIMITER: ${{ inputs.delimiter }}

0 comments on commit 2581181

Please sign in to comment.