Skip to content

sync-labels

sync-labels #60

Workflow file for this run

---
name: sync-labels
on:
schedule:
- cron: '43 0 * * 0'
workflow_dispatch:
inputs:
query:
description: '(Optional) GitHub search query for repos in the Azure organization'
type: string
required: false
default: null
permissions:
issues: write
jobs:
getrepos:
name: get repos
runs-on: ubuntu-latest
env:
query: "terraform-azurerm-avm-"
outputs:
repoarray: ${{ steps.graphql.outputs.repoarray }}
steps:
- name: query GitHub graphql API
id: graphql # TODO replace with CSV output when ready
run: |
RESULT=$(gh api graphql --paginate -f query='query {
search(query: "${{ inputs.query || env.query }} user:azure", type: REPOSITORY, first: 100) {
repositoryCount
edges {
node {
... on Repository {
name
}
}
}
}
}')
NUMREPOS=$(echo $RESULT | jq '.data.search.repositoryCount')
echo "Number of repos found: $NUMREPOS"
REPOARRAY=$(echo $RESULT | jq -c '.data.search.edges | [.[].node.name]')
echo repoarray="$REPOARRAY"
echo repoarray="$REPOARRAY" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.USER_PAT }}
sync-labels:
name: sync
runs-on: ubuntu-latest
needs: getrepos
env:
GITHUB_USER: matt-FFFFFF
outputs:
result: ${{ steps.set-output.outputs.result }}
strategy:
max-parallel: 5
matrix:
repo: ${{ fromJson(needs.getrepos.outputs.repoarray) }}
exclude:
- repo: "terraform-azurerm-avm-template"
fail-fast: false
steps:
- name: run avm github labels script
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Azure/Azure-Verified-Modules/main/docs/static/scripts/Set-AvmGitHubLabels.ps1" -OutFile "./Set-AvmGitHubLabels.ps1"
./Set-AvmGitHubLabels.ps1 -RepositoryName "Azure/${{ matrix.repo }}" -CreateCsvLabelExports $false -RemoveExistingLabels $false -NoUserPrompts $true
echo ${{ matrix.repo }}
env:
GITHUB_TOKEN: ${{ secrets.USER_PAT }}