Skip to content

Commit

Permalink
checkout action repo (#6)
Browse files Browse the repository at this point in the history
* checkout action repo

* update repo name

* add id

* update readme

* rename input

* fix docs
  • Loading branch information
scandar authored Nov 12, 2024
1 parent 710e322 commit 7734bc1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: "main" # use ${{ github.ref_name }} when using this on a real branch
fail-on-missing-codeowners: false
fail_on_missing_codeowners: false

- name: Print Output
id: output
Expand Down
37 changes: 16 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ owner, a comment is added to the PR with the list of orphan files.
### Inputs

- `github_token`: String - Github Token (required)
- `fail-on-missing-codeowners`: Boolean - Fail CI if there are files without
- `fail_on_missing_codeowners`: Boolean - Fail CI if there are files without
owners (default: true)
- `codeowners_path`: String - Path to the codeowners file (default: CODEOWNERS)
- `pr_number`: Number - Scan only the files modified in the PR (optional if
Expand Down Expand Up @@ -83,18 +83,20 @@ permissions:

jobs:
check-codeowners:
name: Check CODEOWNERS
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check CODEOWNERS
id: ownyourcode
uses: getyourguide/ownyourcode@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ github.event.number }}

- name: Print Output
run: |
echo "${{ steps.ownyourcode.outputs.total_orphan_files }}"
echo "${{ steps.ownyourcode.outputs.total_scanned_files }}"
echo "${{ steps.ownyourcode.outputs.failed }}"
```
### Using on a branch
Expand All @@ -106,19 +108,17 @@ on:
push:
branches:
- main

permissions:
id-token: write
contents: read
pull-requests: write # we need this to write comments in PRs
jobs:
check-codeowners:
name: Check CODEOWNERS
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Test Local Action
- name: Check CODEOWNERS
id: ownyourcode
uses: getyourguide/ownyourcode@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -131,26 +131,21 @@ jobs:
---
jobs:
check-codeowners:
name: Check CODEOWNERS
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check CODEOWNERS
id: ownyourcode
uses: getyourguide/ownyourcode@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ github.event.number }}
branch: ${{ github.ref_name }}
fail_on_missing_codeowners: false # important for next step to work

- name: Print Output
id: output
run: |
echo "${{ steps.ownyourcode.outputs.total_orphan_files }}"
echo "${{ steps.ownyourcode.outputs.total_scanned_files }}"
echo "${{ steps.ownyourcode.outputs.failed }}"
echo "Total orphan files: ${{ steps.ownyourcode.outputs.total_orphan_files }}"
echo "Total scanned files: ${{ steps.ownyourcode.outputs.total_scanned_files }}"
echo "Failed: ${{ steps.ownyourcode.outputs.failed }}"
```
## CODEOWNERS file
Expand Down
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ branding:
color: "orange"

inputs:
fail-on-missing-codeowners:
fail_on_missing_codeowners:
description: "Fail CI if there are files without owners"
default: "true"
required: false
Expand Down Expand Up @@ -43,6 +43,8 @@ runs:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
repository: "getyourguide/ownyourcode"

- name: Setup Node.js
id: setup-node
Expand All @@ -57,12 +59,13 @@ runs:
run: npm ci

- name: Check Codeowners
id: codeowners
shell: bash
run: node ./dist/index.js
env:
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
INPUT_CODEOWNERS_PATH: ${{ inputs.codeowners_path }}
INPUT_PR_NUMBER: ${{ inputs.pr_number }}
INPUT_FAIL_ON_MISSING_CODEOWNERS:
${{ inputs.fail-on-missing-codeowners }}
${{ inputs.fail_on_missing_codeowners }}
INPUT_BRANCH: ${{ inputs.branch }}
2 changes: 1 addition & 1 deletion src/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe("OwnYourCode - PR Mode", () => {
);
});

it("should not fail if files have no owners but fail-on-missing-codeowners input is false", async () => {
it("should not fail if files have no owners but fail_on_missing_codeowners input is false", async () => {
inputs.FAIL_ON_MISSING_CODEOWNERS = "false";
vi.spyOn(PrHandler.prototype, "getCodeOwnersFile").mockResolvedValueOnce(
"__FILE-CONTENT__",
Expand Down

0 comments on commit 7734bc1

Please sign in to comment.