Skip to content

ci-repo-watcher

ci-repo-watcher #152

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@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- 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 | keys' - > 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 != '' && env.NEW_REPOSITORIES != '\n' && env.NEW_REPOSITORIES != '[]' }}
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 != '' && env.NEW_REPOSITORIES != '\n' && env.NEW_REPOSITORIES != '[]' }}
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN || secrets.token }}
with:
assignees: CAMOBAP
filename: .github/templates/new-repos.md