Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
irby committed Jul 27, 2023
0 parents commit 0f930ae
Show file tree
Hide file tree
Showing 12 changed files with 11,170 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/sample.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on:
push:
branches:
- main

jobs:
sample:
runs-on: ubuntu-latest
name: Sample
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get PR labels
id: pr-labels
uses: ./
- run: |
env | grep GITHUB_PR_LABEL || true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
lib
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.10.0
10 changes: 10 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"overrides": [
{
"files": "*.yml",
"options": {
"singleQuote": true
}
}
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Matthew H. Irby

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# PR Labels on Push

A Github action that extracts labels from the most recent push and makes them available to other actions. Labels are available as step outputs and environment variables that you can use in later steps in your action.

## How do I use this?

Perhaps you have a test that you only want to run when PR label `release:master` is set. Your workflow should look like this:

```yaml
jobs:
test:
steps:
- name: Get PR labels
id: pr-labels
uses: irby/get-labels-on-push@main

# GITHUB_PR_LABEL_RELEASE_MASTER was set by pr-labels action
- run: |
if [ -n "$GITHUB_PR_LABEL_RELEASE_MASTER" ]; then
echo "This is a release label!"
fi
# or you can use the action output.
# For the label name, use lowercase kebab-case and surround with spaces
- run: |
scripts/release-major.sh
if: contains(steps.pr-labels.outputs.labels, ' release-major ')
```
## Code Based on the Following
[joerick/pr-labels-action](https://github.com/joerick/pr-labels-action)
[shioyang/check-pr-labels-on-push-action](https://github.com/shioyang/check-pr-labels-on-push-action)
22 changes: 22 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Get Labels on Push'
author: irby
description: 'This action will convert all labels from the latest PR into a dictionary to be read by other steps in GitHub Actions pipeline.'
inputs:
github-token: # id of input
description: 'The repository token, i.e. secrets.GITHUB_TOKEN'
required: true
outputs:
labels:
description: |
The labels on this PR. A string containing tag identifiers surrounded
with spaces for easy use with `contains`.
labels-object:
description: |
The labels on this PR. A dictionary containing `true` where a label
exists
runs:
using: 'node16'
main: 'dist/index.js'
branding:
icon: 'tag'
color: 'green'
Loading

0 comments on commit 0f930ae

Please sign in to comment.