Skip to content

Commit

Permalink
Merge pull request #89 from PHPCSStandards/feature/ghactions-safeguar…
Browse files Browse the repository at this point in the history
…d-labeler-more

GH Actions: safeguard the PR label workflow some more
  • Loading branch information
jrfnl authored Nov 11, 2023
2 parents 70ab081 + c7f23e2 commit 5ef2b66
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion .github/workflows/label-new-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,48 @@ name: Label new PRs

on:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
# The `pull_request_target` event is used for "normal" PRs to label them when they are opened.
# This will use the `labeler.yml` file in the default (master) branch of the repo.
pull_request_target:
types:
- opened
- ready_for_review

# The `pull_request` event is used for PRs which change the files which handle the labeling to prevent a silently failing action.
# This will use the `labeler.yml` file in the PR branch.
pull_request:
paths:
- '.github/workflows/label-new-prs.yml'
- '.github/labeler.yml'

jobs:
label-new-prs:
runs-on: ubuntu-latest
if: github.repository_owner == 'PHPCSStandards' && github.event_name == 'pull_request_target'

name: Add labels to new PRs

steps:
- name: Label new PRs
uses: srvaroa/labeler@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

validate-labeler-worflow:
runs-on: ubuntu-latest
if: github.repository_owner == 'PHPCSStandards' && github.event_name == 'pull_request' && github.event.pull_request.merged == false

name: Validate changes to Labeler logic

steps:
- uses: srvaroa/labeler@master
# Checkout is needed to use the `use_local_config` option.
- name: Checkout code
uses: actions/checkout@v3

- name: Verify changes to the labeling logic
uses: srvaroa/labeler@master
with:
use_local_config: true
fail_on_error: true
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

0 comments on commit 5ef2b66

Please sign in to comment.