forked from platformsh/platformsh-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (41 loc) · 1.58 KB
/
check-labels.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Check labels
on:
pull_request_target:
branches: [main]
types: [labeled,opened,reopened,synchronize]
env:
GH_TOKEN: ${{ secrets.WORKFLOW__LABEL_TOKEN }}
jobs:
check-for-upcoming:
runs-on: ubuntu-latest
name: Check if the PR is an upcoming change
steps:
- name: Fail upcoming changes
# If the PR contains the label for future changes, fail the workflow
if: contains(github.event.pull_request.labels.*.name, 'upcoming version')
run: |
echo "This PR deals with a future change and so can't be merged yet"
exit 1
- name: Pass current changes
run: echo "This PR is marked as only involving current changes"
add-markdown-prose-label:
runs-on: ubuntu-latest
if: github.event.action == 'opened' || github.event.action == 'reopened'
steps:
- name: Get repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Verify label exists
shell: bash
run: |
if [[ "${{ vars.LBL_MRKDWNPROSE }}" != $(gh label list --search "${{ vars.LBL_MRKDWNPROSE }}" --json name -q '.[] | .name') ]]; then
echo "Label ${{ vars.LBL_MRKDWNPROSE }} doesn't exist so I need to create it."
gh label create "${{ vars.LBL_MRKDWNPROSE }}"
else
echo "Label ${{ vars.LBL_MRKDWNPROSE }} already exists so no need to create it."
fi
- name: Add prose label
shell: bash
run: |
gh pr edit ${{ github.event.pull_request.number }} --add-label "${{ vars.LBL_MRKDWNPROSE }}"