Skip to content

Provide method to plan without credentials #2404

Provide method to plan without credentials

Provide method to plan without credentials #2404

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 }}
})