Skip to content

ci-repo-watcher

ci-repo-watcher #202

name: ci-repo-watcher
on:
schedule:
- cron: "0 0 * * Mon" # once a week https://crontab.guru/#0_0_*_*
workflow_dispatch:
workflow_call:
secrets:
token:
required: true
jobs:
watcher:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
- name: Setup gh-repo-manifest
run: |
if [ ! -f bin/gh-repo-manifest ]
then
mkdir -p bin
wget https://raw.githubusercontent.com/metanorma/ci/main/bin/gh-repo-manifest -O bin/gh-repo-manifest
fi
- name: Check for new repos
id: cimas-diff
run: |
ruby bin/gh-repo-manifest -o ${{ github.repository_owner }} -m cimas-config/cimas.yml > cimas-diff.yml
cat cimas-diff.yml
yq --version
cat cimas-diff.yml | yq e '.repositories.*.remote' - | sed -e 's|^ssh://git@|- https://|' > new-repos.yml
NEW_REPOSITORIES=$(cat new-repos.yml)
echo "New repositories:"
echo "$NEW_REPOSITORIES"
echo "NEW_REPOSITORIES=${NEW_REPOSITORIES//$'\n'/'\n'}" >> $GITHUB_ENV
- if: ${{ env.NEW_REPOSITORIES != 'null' }}
name: Download template if missing
run: |
if [ ! -f .github/templates/new-repos.md ]
then
mkdir -p .github/templates
wget https://raw.githubusercontent.com/metanorma/ci/main/.github/templates/new-repos.md -O .github/templates/new-repos.md
fi
sed -i -e "s|REPOSITOY_MARKDOWN_LIST|${REPOSITOY_MARKDOWN_LIST}|g" .github/templates/new-repos.md
env:
REPOSITOY_MARKDOWN_LIST: ${{ env.NEW_REPOSITORIES }}
- if: ${{ env.NEW_REPOSITORIES != 'null' }}
uses: ./comment-or-create
with:
token: ${{ secrets.GITHUB_TOKEN || secrets.token }}
title: New repos in ${{ env.GITHUB_REPOSITORY_OWNER }} found
assignees: CAMOBAP
comment: |
Review new discovered repositories during run {{ env.GITHUB_SERVER_URL }}/{{ env.GITHUB_REPOSITORY }}/actions/runs/{{ env.GITHUB_RUN_ID }}:
${{ env.NEW_REPOSITORIES }}
And add them to `cimas-config/cimas.yml` with the right set of `files`