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

feat: add sizeLabel GITHUB_OUTPUT for further reuse in other jobs #44

Merged
merged 2 commits into from
Apr 16, 2024
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
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 @@ -82,6 +82,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 @@ -76,6 +76,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