-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(actions): add repository-owner-is-organization action
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
- Loading branch information
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
.github/workflows/__test-action-repository-owner-is-organization.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Internal - Tests for repository-owner-is-organization action | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
tests: | ||
name: Tests for repository-owner-is-organization action | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- id: repository-owner-is-organization | ||
uses: ./actions/repository-owner-is-organization | ||
|
||
- name: Check repository-owner-is-organization outputs | ||
run: | | ||
if [ "${{ steps.repository-owner-is-organization.outputs.is-organization }}" != 'true' ]; then | ||
echo "repository-owner-is-organization outputs result is not valid" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!-- start branding --> | ||
<!-- end branding --> | ||
<!-- start title --> | ||
|
||
# GitHub Action: Repository owner is organization | ||
|
||
<!-- end title --> | ||
<!-- start badges --> | ||
<!-- end badges --> | ||
<!-- start description --> | ||
|
||
Action to check if the repository owner is an organization. | ||
|
||
<!-- end description --> | ||
<!-- start contents --> | ||
<!-- end contents --> | ||
<!-- start usage --> | ||
|
||
```yaml | ||
- uses: hoverkraft-tech/ci-github-common/actions/repository-owner-is-organization@v0.7.5 | ||
with: | ||
``` | ||
<!-- end usage --> | ||
<!-- start inputs --> | ||
| **Input** | **Description** | **Default** | **Required** | | ||
| ----------------------------- | ------------------------------------ | -------------------------------- | ------------ | | ||
| **<code>github-token</code>** | GitHub token for fetching users API. | <code>${{ github.token }}</code> | **false** | | ||
<!-- end inputs --> | ||
<!-- start outputs --> | ||
| **Output** | **Description** | **Default** | **Required** | | ||
| ---------------------------- | ------------------------------------------------------------------------ | ----------- | ------------ | | ||
| <code>is-organization</code> | The boolean value indicating if the repository owner is an organization. | undefined | undefined | | ||
<!-- end outputs --> | ||
<!-- start [.github/ghadocs/examples/] --> | ||
<!-- end [.github/ghadocs/examples/] --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: "Repository owner is organization" | ||
description: "Action to check if the repository owner is an organization." | ||
author: Hoverkraft | ||
branding: | ||
icon: users | ||
color: gray-dark | ||
|
||
inputs: | ||
github-token: | ||
description: "GitHub token for fetching users API." | ||
default: ${{ github.token }} | ||
required: false | ||
|
||
outputs: | ||
is-organization: | ||
description: "The boolean value indicating if the repository owner is an organization." | ||
value: "${{ steps.check-org.outputs.is-organization }}" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- id: check-org | ||
run: | | ||
OWNER_TYPE=$(curl -s -H "Authorization: token ${{ inputs.github-token }}" \ | ||
"https://api.github.com/users/${{ github.repository_owner }}" | jq -r .type) | ||
if [ "$OWNER_TYPE" = "Organization" ]; then | ||
echo "is-organization=true" >> "$GITHUB_OUTPUT" | ||
fi | ||
shell: bash |