Skip to content

sync-labels

sync-labels #63

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:
- uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- 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: ${{ steps.app-token.outputs.token }}
sync-labels:
name: sync
runs-on: ubuntu-latest
needs: getrepos
strategy:
max-parallel: 5
matrix:
repo: ${{ fromJson(needs.getrepos.outputs.repoarray) }}
exclude:
- repo: "terraform-azurerm-avm-template"
fail-fast: false
steps:
- uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: Azure
repositories: ${{ matrix.repo }}
- 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: ${{ steps.app-token.outputs.token }}