Skip to content

Commit

Permalink
Fixes issue automation
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-jbooz committed Feb 18, 2025
1 parent 54d5f2e commit 1a0bc1f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 76 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/1-documentation-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ body:
- label: "General Docs Update - Not Application Specific"

- type: checkboxes
id: update_type
id: type
attributes:
label: "Type of Update"
description: "Select the type of documentation update."
options:
- label: "New feature"
- label: "New Feature"
- label: "Correction"
- label: "Enhancement"
- label: "Other"
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
30 changes: 30 additions & 0 deletions .github/advanced-issue-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
policy:
- section:
- id: [application]
label:
- name: "Alloy"
keys: ["Alloy"]
- name: "Blueprint"
keys: ["Blueprint"]
- name: "Caster"
keys: ["Caster"]
- name: "CITE"
keys: ["CITE"]
- name: "Gallery"
keys: ["Gallery"]
- name: "Gameboard"
keys: ["Gameboard"]
- name: "Player"
keys: ["Player"]
- name: "Steamfitter"
keys: ["Steamfitter"]
- name: "TopoMojo"
keys: ["TopoMojo"]
- id: [type]
label:
- name: "New Feature"
keys: ["New Feature"]
- name: "Correction"
keys: ["Correction"]
- name: "Enhancement"
keys: ["Enhancement"]
106 changes: 32 additions & 74 deletions .github/workflows/label-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,43 @@ name: Auto-label Documentation Update Issues

on:
issues:
types:
- opened
types: [ opened ]

permissions:
contents: read

jobs:
add-labels:
label-issue:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Extract issue body
id: extract_body
uses: actions/github-script@v7
with:
script: |
const issueBody = context.payload.issue.body;
return issueBody;
- name: Determine labels
id: determine_labels
run: |
LABELS=""

if echo "${{ steps.extract_body.outputs.result }}" | grep -Fq "- \[x\] Alloy"; then
LABELS="$LABELS Alloy"
fi
if echo "${{ steps.extract_body.outputs.result }}" | grep -Fq "- \[x\] Blueprint"; then
LABELS="$LABELS Blueprint"
fi
if echo "${{ steps.extract_body.outputs.result }}" | grep -Fq "- \[x\] Caster"; then
LABELS="$LABELS Caster"
fi
if echo "${{ steps.extract_body.outputs.result }}" | grep -Fq "- \[x\] CITE"; then
LABELS="$LABELS CITE"
fi
if echo "${{ steps.extract_body.outputs.result }}" | grep -Fq "- \[x\] Gallery"; then
LABELS="$LABELS Gallery"
fi
if echo "${{ steps.extract_body.outputs.result }}" | grep -Fq "- \[x\] Gameboard"; then
LABELS="$LABELS Gameboard"
fi
if echo "${{ steps.extract_body.outputs.result }}" | grep -Fq "- \[x\] Player"; then
LABELS="$LABELS Player"
fi
if echo "${{ steps.extract_body.outputs.result }}" | grep -Fq "- \[x\] Steamfitter"; then
LABELS="$LABELS Steamfitter"
fi
if echo "${{ steps.extract_body.outputs.result }}" | grep -Fq "- \[x\] TopoMojo"; then
LABELS="$LABELS TopoMojo"
fi
if echo "${{ steps.extract_body.outputs.result }}" | grep -Fq "- \[x\] General"; then
LABELS="$LABELS General"
fi
permissions:
issues: write

steps:
- uses: actions/checkout@v3

- name: Parse issue form
uses: stefanbuck/github-issue-parser@v3
id: issue-parser
with:
template-path: .github/ISSUE_TEMPLATE/1-documentation-update.yml

if echo "${{ steps.extract_body.outputs.result }}" | grep -q "- \[x\] New feature"; then
LABELS="$LABELS New feature"
fi
if echo "${{ steps.extract_body.outputs.result }}" | grep -q "- \[x\] Correction"; then
LABELS="$LABELS Correction"
fi
if echo "${{ steps.extract_body.outputs.result }}" | grep -q "- \[x\] Enhancement"; then
LABELS="$LABELS Enhancement"
fi
if echo "${{ steps.extract_body.outputs.result }}" | grep -q "- \[x\] Other"; then
LABELS="$LABELS Other"
fi
echo "LABELS=$(echo $LABELS | xargs)" >> $GITHUB_ENV
- name: Add labels to issue
uses: actions/github-script@v7
- name: Set labels based on application field
uses: redhat-plumbers-in-action/advanced-issue-labeler@v3
with:
issue-form: ${{ steps.issue-parser.outputs.jsonString }}
section: application
block-list: |
None
General Docs Update - Not Application Specific
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set labels based on update_type field
uses: redhat-plumbers-in-action/advanced-issue-labeler@v3
with:
script: |
const labels = process.env.LABELS.split(' ');
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labels
});
issue-form: ${{ steps.issue-parser.outputs.jsonString }}
section: update_type
block-list: |
None
Other
token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 1a0bc1f

Please sign in to comment.