2-update-readme-with-github-repositories-details #456
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 2-update-readme-with-github-repositories-details | |
# Update the README with the details of the GitHub repositories | |
# Workflow triggered using GitHub CLI at the end of the execution of the update-gihub-repositories-details workflow - but can also be triggered manually without input parameters | |
on: | |
workflow_dispatch: | |
# Concurrency configuration for the current workflow - Keep only the latest workflow queued for the considered group | |
concurrency: | |
group: update-readme-with-github-repositories-details | |
cancel-in-progress: true | |
jobs: | |
update-readme-with-github-repositories-details: | |
runs-on: ubuntu-latest | |
env: | |
RUNNER_DEBUG: 1 | |
steps: | |
# Action used to checkout the main branch in the current repository | |
# Community action: https://github.com/actions/checkout | |
- name: Checkout | |
uses: actions/checkout@v4.1.1 | |
# Set a current date environment variable in the following format: YYYYMMDD | |
- name: Set current date as env variable | |
id: current_date | |
run: echo "NOW=$(date +'%Y%m%d')" >> $env:GITHUB_OUTPUT | |
shell: pwsh | |
# Set the name of the current day in the week as a variable | |
- name: Set the name of the current day in the week as env variable | |
id: current_day_in_the_week | |
run: echo "DAY=$(date +'%A')" >> $env:GITHUB_OUTPUT | |
shell: pwsh | |
# Update summary and repositories opened to contributions in README | |
- name: Update summary and repositories opened to contributions | |
run: | | |
Write-Host "/********************************************************************************/" | |
Write-Host "Install required modules" | |
Import-Module .\Scripts\Write-MarkdownSection.ps1 -Force | |
Import-Module .\Scripts\Get-ShieldIoBadge.ps1 -Force | |
Import-Module .\Scripts\ConvertTo-MarkdownTable.ps1 -Force | |
Import-Module .\Scripts\Write-ReadmeSummarySection.ps1 -Force | |
Import-Module .\Scripts\Write-ReadmeRepositoriesOpenedToContributionsSection.ps1 -Force | |
Write-Host "/********************************************************************************/" | |
Write-Host "Get search criteria details" | |
# If the file does not exist initialize the variable with an empty array | |
if (Test-Path -Path "${{ vars.CONFIGURATION_FILE_PATH }}") { | |
$topics = Get-Content -Path "${{ vars.CONFIGURATION_FILE_PATH }}" | ConvertFrom-Json | |
} else { | |
$searchCriteria = @() | |
} | |
Write-Host "Get repositories details" | |
# If the file does not exist initialize the variable with an empty array | |
if (Test-Path -Path "${{ vars.DATA_FILE_PATH }}") { | |
$repositoriesDetails = Get-Content -Path "${{ vars.DATA_FILE_PATH }}" | ConvertFrom-Json | |
} else { | |
$repositoriesDetails = @() | |
} | |
Write-Host "/********************************************************************************/" | |
Write-Host "Update summary" | |
Write-ReadmeSummarySection -GitHubRepositoriesDetails $repositoriesDetails -Topics $topics | |
Write-Host "/********************************************************************************/" | |
Write-Host "Update list of repositories opened to contributions" | |
Write-ReadmeRepositoriesOpenedToContributionsSection -GitHubRepositoriesDetails $repositoriesDetails | |
shell: pwsh | |
# If the current day in the week is Monday, update the list of top growing repositories | |
- name: Update list of top growing repositories | |
if: ${{ steps.current_day_in_the_week.outputs.DAY == 'Monday' }} | |
run: | | |
Write-Host "Current day of the week: ${{ steps.current_day_in_the_week.outputs.DAY }}" | |
Write-Host "/********************************************************************************/" | |
Write-Host "Install required modules" | |
Import-Module .\Scripts\Write-MarkdownSection.ps1 -Force | |
Import-Module .\Scripts\Get-ShieldIoBadge.ps1 -Force | |
Import-Module .\Scripts\ConvertTo-MarkdownTable.ps1 -Force | |
Import-Module .\Scripts\Write-ReadmeTopGrowingRepositoriesSection.ps1 -Force | |
Write-Host "/********************************************************************************/" | |
Write-Host "Get repositories details" | |
# If the file does not exist initialize the variable with an empty array | |
if (Test-Path -Path "${{ vars.DATA_FILE_PATH }}") { | |
$repositoriesDetails = Get-Content -Path "${{ vars.DATA_FILE_PATH }}" | ConvertFrom-Json | |
} else { | |
$repositoriesDetails = @() | |
} | |
Write-Host "Get latest snapshot of the popularity score of the GitHub repositories" | |
# If the file does not exist initialize the variable with an empty array | |
if (Test-Path -Path "${{ vars.DATA_SNAPSHOT_FILE_PATH }}") { | |
$repositoriesPopularityScoresSnapshot = Get-Content -Path "${{ vars.DATA_SNAPSHOT_FILE_PATH }}" | ConvertFrom-Json | |
} else { | |
$repositoriesPopularityScoresSnapshot = @() | |
} | |
Write-Host "/********************************************************************************/" | |
Write-Host "Update list of top growing repositories" | |
Write-ReadmeTopGrowingRepositoriesSection -GitHubRepositoriesDetails $repositoriesDetails -GitHubRepositoriesPopularityScoresSnapshot $repositoriesPopularityScoresSnapshot | |
shell: pwsh | |
# Push the changes in the current repository | |
- name: Push changes | |
run: | | |
git config --global user.name 'action@github.com' | |
git config --global user.email 'GitHub Action' | |
git add --all | |
git commit -m "Information regarding referenced GitHub repositories updated in README - ${{ steps.current_date.outputs.NOW }}.${{ github.run_number }}" | |
git -c http.extraheader="AUTHORIZATION: Bearer ${{ secrets.GITHUB_TOKEN }}" push origin main | |
shell: pwsh | |
# If the current day in the week is Monday, trigger the snapshot-github-repositories-popularity-score workflow in the current repository using GitHub CLI | |
- name: Trigger snapshot-github-repositories-popularity-score workflow | |
if: ${{ steps.current_day_in_the_week.outputs.DAY == 'Monday' }} | |
run: | | |
gh workflow run snapshot-github-repositories-popularity-score.yml --ref main | |
shell: pwsh | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_WORKFLOW_UPDATE }} |