This repository has been archived by the owner on Jun 14, 2024. It is now read-only.
forked from hashicorp/terraform-provider-google
-
Notifications
You must be signed in to change notification settings - Fork 2
49 lines (47 loc) · 1.64 KB
/
service-labeler.yml
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
46
47
48
49
name: Service Labeler
on:
issues:
types: [opened, edited, unlabeled]
jobs:
add-labels:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Checkout magic modules
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: GoogleCloudPlatform/magic-modules
ref: main
path: magic-modules
- name: Setup go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: '>=1.19.0'
- name: Check for service labels
id: service_labels
run: |
serviceLabels="$(echo '${{ toJson(github.event.issue.labels.*.name) }}' | jq -c 'map(select(startswith("service/")))')"
echo "Service labels: $serviceLabels"
echo "service_labels=$serviceLabels" >> $GITHUB_OUTPUT
- name: Pick labels
id: pick_labels
if: ${{ steps.service_labels.outputs.service_labels == '[]' }}
env:
ISSUE_BODY: ${{ github.event.issue.body }}
run: |
cd magic-modules/tools/issue-labeler
labels=$(go run .)
echo "Labels: $labels"
echo "labels=$labels" >> $GITHUB_OUTPUT
- name: Apply labels
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: ${{ steps.service_labels.outputs.service_labels == '[]' && steps.pick_labels.outputs.labels != '' }}
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ${{ steps.pick_labels.outputs.labels }}
})