Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Workflow with Detailed Summaries and Improved Deployment #11

Merged
merged 6 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .github/workflows/doit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ jobs:
- name: Run app
if: ${{ github.actor == github.repository_owner }}
run: |
echo "kaggle kernels download process" > $GITHUB_STEP_SUMMARY
python main.py
echo "kaggle kernels downloaded" > $GITHUB_STEP_SUMMARY

- name: ReZip kernels
if: ${{ github.actor == github.repository_owner }}
Expand All @@ -83,9 +85,10 @@ jobs:
fi
mkdir -p tmp
7z x kernels.zip -otmp
echo "kernels.7z creation" > $GITHUB_STEP_SUMMARY
7z a -t7z -mx=9 -p"${{ secrets.ARCHIVE_PASSWORD }}" kernels.7z tmp/*
echo "archive_created=true" >> $GITHUB_ENV
echo "kernels.7z has been created" >> $GITHUB_STEP_SUMMARY
echo "kernels.7z has been created" > $GITHUB_STEP_SUMMARY
rm -rf tmp || :

- name: Upload Archive Artifact
Expand All @@ -109,6 +112,7 @@ jobs:
echo "DESTINATION_REPOSITORY_NAME secret is not set"
else
export DESTINATION_REPOSITORY_NAME="${{ secrets.DESTINATION_REPOSITORY_NAME }}"
echo "DESTINATION_REPOSITORY_NAME set from secrets"
fi
fi

Expand All @@ -122,20 +126,21 @@ jobs:

rm -rf tmp || :
mkdir -p tmp
echo "Extract archive" >> $GITHUB_STEP_SUMMARY
echo "Extract archive" > $GITHUB_STEP_SUMMARY

7z x kernels.zip -otmp

echo "DEPLOY_TO_REPOSITORY=true" >> $GITHUB_ENV
echo "DEPLOY_TO_REPOSITORY prepared" >> $GITHUB_STEP_SUMMARY

- name: Push kernelsdirectory to another repository
- name: Push kernels directory to another repository
uses: cpina/github-action-push-to-another-repository@v1
if: ${{ env.DEPLOY_TO_REPOSITORY == 'true' && github.actor == github.repository_owner }}
with:
source-directory: tmp
destination-github-username: ${{ env.DESTINATION_REPOSITORY_USERNAME || github.actor }}
user-name: ${{ env.DESTINATION_REPOSITORY_USERNAME || github.actor }}
user-email: ${{ env.DESTINATION_REPOSITORY_USERNAME || github.actor }}@users.noreply.github.com
user-name: ${{ github.actor }}
user-email: ${{ github.actor }}@users.noreply.github.com
destination-repository-name: ${{ env.DESTINATION_REPOSITORY_NAME }}
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
Expand Down
7 changes: 4 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import logging
import os
import shutil
from pathlib import Path
from tempfile import TemporaryDirectory
Expand Down Expand Up @@ -61,13 +62,13 @@ def kernel_to_path(kernel):
return Path(pathvalidate.sanitize_filename(f"{kernel.ref}#{kernel.id}", replacement_text="_"))


def main(include_private=True, max_page_size=MAX_PAGE_SIZE, user=None, output_name="kernels.zip",
def main(include_private=False, max_page_size=MAX_PAGE_SIZE, user=None, output_name="kernels.zip",
tmp_dir_prefix="kaggle_", tmp_dir=None):
parser = argparse.ArgumentParser(description="Download All Kaggle Kernels")
parser.add_argument("-o", "--output", type=validate_filename, default=output_name,
help="Name of the output zip file (default: kernels.zip)")
parser.add_argument("-p", "--include-private", action="store_true", default=include_private,
help="Include private kernels in the download (default: True)")
help="Include private kernels in the download (default: False)")
parser.add_argument("-u", "--user", type=str, default=user,
help="Username of the Kaggle user to search kernels for (default: current user)")
parser.add_argument("-s", "--max-page-size", type=validate_positive_int, default=max_page_size,
Expand Down Expand Up @@ -120,4 +121,4 @@ def main(include_private=True, max_page_size=MAX_PAGE_SIZE, user=None, output_na


if __name__ == '__main__':
main()
main(include_private=os.getenv('KAGGLE_KERNELS_PRIVATE', '').lower() in ('true', '1', 'y', 'yes', 'ok'))
Loading