Skip to content

profile automation #970

profile automation

profile automation #970

Workflow file for this run

name: profile automation
on:
push:
schedule:
- cron: '0 4 * * 1-6'
workflow_dispatch:
jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: retrieve repositories
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$repos = gh repo list Dexmach --public --json isArchived,name,repositoryTopics,url
$repoList = ($repos | ConvertFrom-Json) | Sort-Object -property name
$archivedRepos = $repoList.where({$_.IsArchived -eq $true})
$aiwRepos = $repoList.where({($_.RepositoryTopics.name -eq 'aiw') -and ($_.IsArchived -eq $false)})
$ossRepos = $repoList.where({($_.RepositoryTopics.name -eq 'oss') -and ($_.IsArchived -eq $false)})
$readme = get-content ./profile/README.md -raw
$aiwOutput = "`r`n"
$ossOutput = "`r`n"
$archiveOutput = "`r`n"
foreach ($repo in $aiwRepos){$aiwOutput+= "- `[{0}`]({1}) `r`n" -f $repo.Name, $repo.url }
foreach ($repo in $ossRepos){$ossOutput+= "- [{0}]({1}) `r`n" -f $repo.Name, $repo.url }
foreach ($repo in $archivedRepos){$archiveOutput+= "- [{0}]({1}) `r`n" -f $repo.Name, $repo.url }
$aiwPattern = "(?s)<!-- AIW START -->\r\n(.*?)\r\n<!-- AIW END -->"
$aiwResult = [regex]::match($readme,$aiwpattern).Groups[1].Value
if(![string]::IsNullOrEmpty($aiwOutput.trim())){
$aiwOutput = $aiwOutput
$readme = $readme.replace($aiwResult, $aiwOutput.replace('$', '$$'))
}
$ossPattern = "(?s)<!-- OSS START -->\r\n(.*?)\r\n<!-- OSS END -->"
$ossResult = [regex]::match($readme,$ossPattern).Groups[1].Value
if(![string]::IsNullOrEmpty($ossOutput.trim())){
$readme = $readme.replace($ossResult, $ossOutput.replace('$', '$$'))
}
$archivePattern = "(?s)<!-- ARCHIVE START -->\r\n(.*?)\r\n<!-- ARCHIVE END -->"
$archiveResult = [regex]::match($readme,$archivepattern.trim()).Groups[1].Value
if(![string]::IsNullOrEmpty($archiveOutput)){
$readme = $readme.replace($archiveResult, $archiveOutput.replace('$', '$$'))
}
$readme
Set-Content -Path ./profile/README.md -Value $readme -Force
- name: Commit profile README.MD
run : |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit --allow-empty -m "update list of repos"
git push