Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
docs: add description of relative option
Browse files Browse the repository at this point in the history
  • Loading branch information
technote-space committed Jul 2, 2021
1 parent 3cca3c0 commit 833fd9c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,35 @@ Run echo '["yarn.lock"]' | jq .
]
```

### 相対パスを指定

GitHub Actions は `uses``working-directory` を指定できないため、モノレポ構成などで個別に実行したい場合に対応できませんが、`RELATIVE` オプションを指定すると `git diff``--relative=<RELATIVE>` として使用されます。

https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---relativeltpathgt

```yaml
on: pull_request
name: CI
jobs:
dump:
name: Dump
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: '*.ts'
RELATIVE: 'src/abc'
- run: echo ${{ env.GIT_DIFF }}
```

`src/abc/test1.ts`, `src/abc/test2.ts`, `src/abc/test3.txt`, `src/test4.ts` のファイルがある場合、結果は以下のようになります。

```shell
> Run echo 'test1.ts' 'test2.ts'
test1.ts test2.ts
```

## Author
[GitHub (Technote)](https://github.com/technote-space)

Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,33 @@ Run echo '["yarn.lock"]' | jq .
]
```

### Specify a relative path

GitHub Actions doesn't support `working-directory` for `uses`, so you can't run this action separately for monorepo configuration, etc. However, if you specify the `RELATIVE` option, it will be used as `--relative=<RELATIVE>` for `git diff`.

```yaml
on: pull_request
name: CI
jobs:
dump:
name: Dump
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: '*.ts'
RELATIVE: 'src/abc'
- run: echo ${{ env.GIT_DIFF }}
```

If the files `src/abc/test1.ts`, `src/abc/test2.ts`, `src/abc/test3.txt`, and `src/test4.ts` exist, the result will be as follows:

```shell
> Run echo 'test1.ts' 'test2.ts'
test1.ts test2.ts
```

## Author
[GitHub (Technote)](https://github.com/technote-space)

Expand Down

0 comments on commit 833fd9c

Please sign in to comment.