Skip to content

Cloud Deploy Deploy Policy resource #4008

Cloud Deploy Deploy Policy resource

Cloud Deploy Deploy Policy resource #4008

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: Build issue-labeler binary
run: |
cd magic-modules/tools/issue-labeler
go build .
- name: Compute new labels
id: compute_new_labels
if: ${{ steps.service_labels.outputs.service_labels == '[]' }}
env:
ISSUE_BODY: ${{ github.event.issue.body }}
run: |
cd magic-modules/tools/issue-labeler
labels=$(./issue-labeler compute-new-labels)
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.compute_new_labels.outputs.labels != '' }}
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ${{ steps.compute_new_labels.outputs.labels }}
})