Skip to content
Closed
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
61 changes: 61 additions & 0 deletions .github/workflows/labeller.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Labeller

on:
workflow_call:
inputs:
label_name:
required: true
type: string
label_color:
required: true
type: string
org_membership:
required: true
type: string
secrets:
token:
required: true

jobs:
communityLabeller:
runs-on: ubuntu-latest
steps:
- name: Label issues or pull requests
id: labeller
uses: puppetlabs/community-labeller@v0
with:
label_name: ${{ github.event.inputs.label_name }}
label_color: ${{ github.event.inputs.label_color }}
org_membership: ${{ github.event.inputs.org_membership }}
token: ${{ secrets.IAC_COMMUNITY_LABELER }}

labelValidator:
needs: communityLabeller
name: Validate label exists
runs-on: ubuntu-latest
steps:
- name: Check for Labels
uses: actions/github-script@v6
with:
script: |
async function getPullRequest() {
Copy link
Contributor

@jordanbreen28 jordanbreen28 Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this logic not be implemented into puppetlabs/community-labeller@v0 and the trigger updated to run on the label created/deleted event in the parent workflow? (by trigger in the parent workflow, I mean like here)

I left some comments on puppetlabs/community-labeller#265 as well.

// Get current pull request labels
const { data: { labels } } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.number,
});

// Log found label names
for (const label of labels) {
core.info(`Found label named '${label.name}' on pull request number ${context.payload.number}`);
}

// Fail workflow if no labels exist
const labelsExist = labels.length > 0;
if (!labelsExist) {
core.setFailed(`Please ensure that a label exists on pull request number ${context.payload.number}`);
}
}

await getPullRequest();