Skip to content

Commit

Permalink
Updated github actions to use cobra-based issue labeler (hashicorp#20558
Browse files Browse the repository at this point in the history
)
  • Loading branch information
melinath authored Dec 4, 2024
1 parent 98fbd43 commit 5e494d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/backfill-issue-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: GoogleCloudPlatform/magic-modules
path: repo
path: magic-modules
- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: '^1.19.1'
- name: Build issue-labeler binary
run: |
cd magic-modules/tools/issue-labeler
go build .
- name: Run backfill
env:
GITHUB_TOKEN: ${{github.token}}
SINCE: ${{ inputs.since || '1973-01-01' }}
DRY_RUN: ${{ contains(inputs.dry_run, 'true') }}
run: |
cd repo/tools/issue-labeler
go run . -backfill-date=${{env.SINCE}} -backfill-dry-run=${{env.DRY_RUN}} -logtostderr=true
cd magic-modules/tools/issue-labeler
./issue-labeler backfill-issue-labels --since=${{env.SINCE}}
14 changes: 9 additions & 5 deletions .github/workflows/service-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,28 @@ jobs:
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
- 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=$(go run .)
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.pick_labels.outputs.labels != '' }}
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.pick_labels.outputs.labels }}
labels: ${{ steps.compute_new_labels.outputs.labels }}
})

0 comments on commit 5e494d1

Please sign in to comment.