ci-repo-watcher #118
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: ci-repo-watcher | |
on: | |
schedule: | |
- cron: "0 0 * * *" # once a day 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 | |
bundler-cache: true | |
- 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=${NEW_REPOSITORIES//$'\n'/<br/>}" >> $GITHUB_ENV | |
echo "New repositories:" | |
echo "$NEW_REPOSITORIES" | |
- if: ${{ env.NEW_REPOSITORIES != '' && env.NEW_REPOSITORIES != '\n' }} | |
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 | |
- if: ${{ env.NEW_REPOSITORIES != '' }} | |
uses: JasonEtco/create-an-issue@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN || secrets.token }} | |
with: | |
assignees: CAMOBAP | |
update_existing: true | |
search_existing: all | |
filename: .github/templates/new-repos.md |