feat: clone sanitychecks from plugin repository #7
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: Gather Sanity Checks | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: {} | |
schedule: | |
- cron: "0 20 * * *" | |
jobs: | |
gather: | |
name: Gather Sanity Checks | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Get all sanity check from remote repository | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
DESTINATION_PATH=src/test/resources/sanity-checks/ | |
REPOSITORIES=$(gh repo list kestra-io -L 1000 --json name | jq -r .[].name | sort | grep "^plugin-") | |
mkdir -p /tmp/repositories /tmp/results | |
cd /tmp/repositories | |
for REPOSITORY in $REPOSITORIES | |
do | |
git clone --filter=blob:none --sparse https://$GH_TOKEN:@github.com/kestra-io/$REPOSITORY.git | |
cd $REPOSITORY | |
git sparse-checkout init --cone | |
git sparse-checkout add $DESTINATION_PATH | |
if test -d $DESTINATION_PATH; then | |
COUNT=$(find $DESTINATION_PATH -type f | wc -l) | |
else | |
COUNT=0 | |
fi | |
if [ "$COUNT" -gt "0" ]; then | |
mkdir -p ../../results/$REPOSITORY | |
cp -R $DESTINATION_PATH* ../../results/$REPOSITORY | |
echo -e "\x1B[32m-> $REPOSITORY - $COUNT found \x1B[0m" | |
else | |
echo -e "\x1B[31m-> $REPOSITORY - No sanity check found \x1B[0m" | |
fi | |
cd .. | |
rm -rf $REPOSITORY | |
done | |
rm -rf plugin-* | |
- name: Prepare the commit | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
mkdir -p sanitychecks/plugins | |
rm -rf sanitychecks/plugins | |
cp -R /tmp/results/ sanitychecks/plugins | |
git add * | |
- name: Check for changes and commit | |
run: | | |
if git diff --cached --quiet; then | |
echo -e "\x1B[32m-> No changes to commit. Exiting with success. \x1B[0m" | |
exit 0 | |
fi | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git commit -m "chore: add sanity check from plugin repository" | |
git push origin main | |
echo -e "\x1B[32m-> Pushing to main. \x1B[0m" |