Skip to content

Commit

Permalink
Adding GitHub action that enforces FINOS blueprint
Browse files Browse the repository at this point in the history
This action runs on a cron and invokes a metadata-tool action.

It generates a report of all missing configurations across all github.com/finos repos.

Based on that, it will create issues for all repos, assuming there is no issue on that repo with the same title.

See Issue finos#31
  • Loading branch information
maoo committed Mar 23, 2020
1 parent c1c731b commit edf08d9
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/project-blueprint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: project-blueprint-action

# This GitHub action checks all FINOS GitHub repositories against a list of validations, and opens an issue on the repository with the missing items.
# If the issue already exists, it skips the repository
on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 0 1 * *'

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FINOS_TOKEN: ${{ secrets.FINOS_TOKEN }}
ISSUE_TITLE: "[FINOS_PROJECT_BLUEPRINT] - Fixes to apply"

jobs:
create-issues:
runs-on: ubuntu-latest
steps:
- name: Install jq
run: sudo apt-get install jq
- name: Checking out metadata-tool
uses: actions/checkout@v2
with:
repository: 'finos/metadata-tool'
path: 'metadata-tool'
ref: blueprint-check
- name: Checking out FINOS metadata
run: git clone https://finos-admin:[email protected]/finos-admin/metadata.git >/dev/null
- name: Generating repository validation
run: curl -s https://raw.githubusercontent.com/finos/open-developer-platform/master/scripts/generate-repo-validation.sh | bash
- name: Checking existing issues
run: curl -s https://raw.githubusercontent.com/finos/open-developer-platform/master/scripts/check-existing-issues.sh | bash
35 changes: 35 additions & 0 deletions scripts/generate-repo-issues.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# This script generates the repo issues

generate_post_data()
{
cat <<EOF
{
"title": "$ISSUE_TITLE",
"body": "$ISSUE_DESCRIPTION"
}
EOF
}

if [ -z $ISSUE_TITLE ]; then
ISSUE_TITLE="[FINOS_PROJECT_BLUEPRINT] - Fixes to apply"
fi

rm -rf /tmp/existing-issues.txt

# Generate list of repos that already have an issue created with $ISSUE_TITLE
curl -s -G "https://api.github.com/search/issues" --data-urlencode "q='$ISSUE_TITLE' in:title org:finos" -H "Accept: application/vnd.github.preview" | jq '.items[] | (.repository_url/"/" | (.[-2] + "/" + .[-1]))' | tr -d '"' | sort | uniq > /tmp/existing-issues.txt

cat metadata-tool/finos-repo-validation.json | jq -r '.[]| [.org, .["repo-name"]] | @tsv' |
while IFS=$'\t' read -r ORG REPO; do
ISSUE_EXIST=`cat /tmp/existing-issues.txt | grep "$ORG/$REPO"`
if [ -z "$ISSUE_EXIST" ]; then
cat finos-repo-validation.json | jq -r '.[] | select(.org == env.ORG and .["repo-name"] == env.REPO) | .message' > /tmp/$ORG-$REPO-issue-description.txt
echo "Creating issue for repo $ORG/$REPO; text generated into /tmp/$ORG-$REPO-issue-description.txt"
echo "Still disabled! Waiting for community announcement"
# curl -d "$(generate_post_data)" https://api.github.com/repos/$ORG/$REPO/issues
# echo curl -d "$(generate_post_data)" https://api.github.com/repos/$ORG/$REPO/issues
echo --------
fi
done
11 changes: 11 additions & 0 deletions scripts/generate-repo-validation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# This script generates the repo validation

# Avoid metadata tool failure
export BITERGIA_USER="empty"
export BITERGIA_PASSWORD="empty"

# Append Meeting addendance data
cd metadata-tool
lein run -- check-project-repos -m ../metadata

0 comments on commit edf08d9

Please sign in to comment.