Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ› fix(token): change gh token for inputs #3

Merged
merged 2 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}