Skip to content

Self Service Log Ingestion #1772

Self Service Log Ingestion

Self Service Log Ingestion #1772

name: Add appropriate labels to issue
on:
issues:
types: [assigned]
jobs:
build_user_list:
name: Get yaml config of GS users
runs-on: ubuntu-latest
steps:
- name: Get user-mapping
run: |
mkdir -p artifacts
wget --header "Authorization: token ${{ secrets.ISSUE_AUTOMATION }}" \
-O artifacts/users.yaml \
https://raw.githubusercontent.com/giantswarm/github/main/tools/issue-automation/user-mapping.yaml
- name: Upload Artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: users
path: artifacts/users.yaml
retention-days: 1
add_label:
name: Add team label when assigned
runs-on: ubuntu-latest
needs: build_user_list
steps:
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
id: download-users
with:
name: users
- name: Find team label based on user names
run: |
event_assignee=$(cat $GITHUB_EVENT_PATH | jq -r .assignee.login | tr '[:upper:]' '[:lower:]')
echo "Issue assigned to: ${event_assignee}"
TEAMS=$(cat ${{steps.download-users.outputs.download-path}}/users.yaml | tr '[:upper:]' '[:lower:]' | yq ".${event_assignee}.teams" -o csv | tr ',' ' ')
echo "LABEL<<EOF" >> $GITHUB_ENV
for team in ${TEAMS}; do
echo "Team: ${team} | Label: team/${team}"
echo "team/${team}" >> $GITHUB_ENV
done
echo "EOF" >> $GITHUB_ENV
- name: Apply label to issue
if: ${{ env.LABEL != '' && env.LABEL != 'null' && env.LABEL != null }}
uses: actions-ecosystem/action-add-labels@bd52874380e3909a1ac983768df6976535ece7f8 # v1.1.3
with:
github_token: ${{ secrets.ISSUE_AUTOMATION }}
labels: |
${{ env.LABEL }}