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

on:
pull_request:
Copy link
Contributor

Choose a reason for hiding this comment

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

This workflow will not be triggered just on PRs to this repo, this is a reusable workflow so requires the workflow_call trigger also. Refer to the other workflows in this repo

types:
- opened
- labeled
- unlabeled

jobs:
label:
runs-on: ubuntu-latest
steps:
- name: Label issues or pull requests
uses: puppetlabs/community-labeller@v0
with:
label_name: community
label_color: '5319e7'
org_membership: puppetlabs
token: ${{ secrets.IAC_COMMUNITY_LABELER }}

test:
Copy link
Contributor

Choose a reason for hiding this comment

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

job name isn't appropriate

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();