Skip to content

Commit

Permalink
feat: add sizeLabel GITHUB_OUTPUT for further reuse in other jobs (#44)
Browse files Browse the repository at this point in the history
* Add sizeLabel GITHUB_OUTPUT for further reuse in other jobs

* Add sizeLabel GITHUB_OUTPUT for further reuse in other jobs

---------

Co-authored-by: Pascal <pascal.gruen@gmail.com>
  • Loading branch information
mat3e and pascalgn committed Apr 16, 2024
1 parent 316f8ac commit 15c9038
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,35 @@ jobs:
}
```

## Using with other actions

If creating workflow with multiple jobs, they can react on the label set by this action:

```yaml
name: size-label
on: pull_request_target
jobs:
label:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
outputs:
label: ${{ steps.label.outputs.sizeLabel }}
steps:
- name: size-label
id: label
uses: "pascalgn/size-label-action@v0.5.0"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
comment:
runs-on: ubuntu-latest
needs: label
if: ${{ contains(needs.label.outputs.label, 'XL') }}
steps:
- run: echo "Too big PR"
```

## License

[MIT](LICENSE)
6 changes: 6 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ async function main() {
const sizeLabel = getSizeLabel(changedLines, sizes);
console.log("Matching label:", sizeLabel);

const githubOutput = process.env.GITHUB_OUTPUT;
if (githubOutput) {
fs.writeFileSync(githubOutput, `sizeLabel="${sizeLabel}"`);
debug(`Written label '${sizeLabel}' to ${githubOutput}`);
}

const { add, remove } = getLabelChanges(
sizeLabel,
eventData.pull_request.labels
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ async function main() {
const sizeLabel = getSizeLabel(changedLines, sizes);
console.log("Matching label:", sizeLabel);

const githubOutput = process.env.GITHUB_OUTPUT;
if (githubOutput) {
fs.writeFileSync(githubOutput, `sizeLabel="${sizeLabel}"`);
debug(`Written label '${sizeLabel}' to ${githubOutput}`);
}

const { add, remove } = getLabelChanges(
sizeLabel,
eventData.pull_request.labels
Expand Down

0 comments on commit 15c9038

Please sign in to comment.