├── README.md ├── .prettierrc.toml ├── .github ├── dependabot.yml └── workflows │ ├── build-pr.yaml │ └── preview-pr.yaml ├── pyproject.toml ├── setup.cfg ├── .pre-commit-config.yaml ├── LICENSE └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # gh-action-playground 2 | -------------------------------------------------------------------------------- /.prettierrc.toml: -------------------------------------------------------------------------------- 1 | tabWidth = 2 2 | semi = false 3 | singleQuote = true 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # - package-ecosystem: pip 4 | # directory: "/" 5 | # schedule: 6 | # interval: daily 7 | - package-ecosystem: 'github-actions' 8 | directory: '/' 9 | schedule: 10 | # Check for updates once a week 11 | interval: 'weekly' 12 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.black] 2 | line-length = 100 3 | target-version = ['py38'] 4 | skip-string-normalization = true 5 | 6 | [tool.nbqa.mutate] 7 | isort = 1 8 | black = 1 9 | pyupgrade = 1 10 | 11 | [tool.nbqa.addopts] 12 | pyupgrade = ["--py36-plus"] 13 | 14 | [build-system] 15 | requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm"] 16 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [flake8] 2 | exclude = 3 | ignore = E203,E266,E501,W503,E722,E402,C901,E731 4 | max-line-length = 100 5 | max-complexity = 18 6 | select = B,C,E,F,W,T4,B9 7 | 8 | [isort] 9 | known_first_party= 10 | known_third_party= 11 | multi_line_output=3 12 | include_trailing_comma=True 13 | force_grid_wrap=0 14 | combine_as_imports=True 15 | line_length=100 16 | skip= 17 | docs/source/conf.py 18 | setup.py 19 | -------------------------------------------------------------------------------- /.github/workflows/build-pr.yaml: -------------------------------------------------------------------------------- 1 | name: build-pr 2 | 3 | # Only run this when the master branch changes 4 | on: 5 | push: 6 | pull_request: 7 | workflow_dispatch: 8 | jobs: 9 | build-pr: 10 | runs-on: ubuntu-latest 11 | defaults: 12 | run: 13 | shell: bash -l {0} 14 | if: github.repository == 'ml-en-action/gh-action-playground' 15 | steps: 16 | - uses: actions/checkout@v2 17 | - name: Building Book 18 | run: | 19 | echo "Building Book" 20 | sleep 10 21 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.0.1 4 | hooks: 5 | - id: trailing-whitespace 6 | - id: end-of-file-fixer 7 | - id: check-docstring-first 8 | - id: check-json 9 | - id: check-yaml 10 | - id: double-quote-string-fixer 11 | 12 | - repo: https://github.com/psf/black 13 | rev: 21.9b0 14 | hooks: 15 | - id: black-jupyter 16 | 17 | - repo: https://github.com/keewis/blackdoc 18 | rev: v0.3.4 19 | hooks: 20 | - id: blackdoc 21 | 22 | - repo: https://github.com/PyCQA/flake8 23 | rev: 3.9.2 24 | hooks: 25 | - id: flake8 26 | 27 | - repo: https://github.com/PyCQA/isort 28 | rev: 5.9.3 29 | hooks: 30 | - id: isort 31 | 32 | - repo: https://github.com/pre-commit/mirrors-prettier 33 | rev: v2.4.1 34 | hooks: 35 | - id: prettier 36 | 37 | - repo: https://github.com/nbQA-dev/nbQA 38 | rev: 1.1.1 39 | hooks: 40 | - id: nbqa-pyupgrade 41 | additional_dependencies: [pyupgrade==2.7.3] 42 | - id: nbqa-isort 43 | additional_dependencies: [isort==v5.9.2] 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Machine Learning en action 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /.github/workflows/preview-pr.yaml: -------------------------------------------------------------------------------- 1 | name: preview-pr 2 | on: 3 | workflow_run: 4 | workflows: 5 | - build-pr 6 | types: 7 | - completed 8 | - requested 9 | 10 | jobs: 11 | deploy: 12 | if: github.repository == 'ml-en-action/gh-action-playground' 13 | runs-on: ubuntu-latest 14 | defaults: 15 | run: 16 | shell: bash 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Set message value 20 | run: | 21 | echo "comment_message=This pull request is being automatically built with GitHub Action + Netlify. To see the status of your deployment, click below." >> $GITHUB_ENV 22 | 23 | - name: Find Pull Request 24 | uses: actions/github-script@v4 25 | id: find-pull-request 26 | with: 27 | script: | 28 | let pullRequestNumber = '' 29 | let pullRequestHeadSHA = '' 30 | 31 | core.info('Finding pull request...') 32 | core.info(`workflow_run payload: ${JSON.stringify(context.payload.workflow_run, null, 2)}`) 33 | const pullRequests = await github.pulls.list({owner: context.repo.owner, repo: context.repo.repo}) 34 | for (let pullRequest of pullRequests.data) { 35 | 36 | if(pullRequest.head.sha === context.payload.workflow_run.head_commit.id) { 37 | pullRequestHeadSHA = pullRequest.head.sha 38 | pullRequestNumber = pullRequest.number 39 | break 40 | 41 | } 42 | } 43 | 44 | core.setOutput('number', pullRequestNumber) 45 | core.setOutput('sha', pullRequestHeadSHA) 46 | 47 | if(pullRequestNumber === '') { 48 | core.info( 49 | `No pull request associated with git commit SHA: ${context.payload.workflow_run.head_commit.id}` 50 | ) 51 | } 52 | else{ 53 | core.debug(`Found pull request ${pullRequestNumber}`) 54 | } 55 | 56 | core.info(`workflow payload: ${JSON.stringify(context.payload, null, 2)}`) 57 | 58 | - name: Get result 59 | run: | 60 | echo "${{ steps.find-pull-request.outputs.number }}" 61 | echo "${{ steps.find-pull-request.outputs.sha }}" 62 | 63 | - name: Find Comment 64 | uses: peter-evans/find-comment@v1 65 | if: steps.find-pull-request.outputs.number != '' 66 | id: fc 67 | with: 68 | issue-number: '${{ steps.find-pull-request.outputs.number }}' 69 | comment-author: 'github-actions[bot]' 70 | body-includes: '${{ env.comment_message }}' 71 | 72 | - name: Create comment 73 | if: | 74 | github.event.workflow_run.conclusion != 'success' 75 | && steps.fc.outputs.comment-id == '' 76 | uses: peter-evans/create-or-update-comment@v1 77 | with: 78 | issue-number: ${{ steps.find-pull-request.outputs.number }} 79 | body: | 80 | ${{ env.comment_message }} 81 | 82 | 🚧 Deployment in progress for git commit SHA: ${{ steps.find-pull-request.outputs.sha }} 83 | 84 | - name: Update comment 85 | if: | 86 | github.event.workflow_run.conclusion != 'success' 87 | && steps.fc.outputs.comment-id != '' 88 | uses: peter-evans/create-or-update-comment@v1 89 | with: 90 | token: ${{ steps.generate-token.outputs.token }} 91 | comment-id: ${{ steps.fc.outputs.comment-id }} 92 | edit-mode: replace 93 | body: | 94 | ${{ env.comment_message }} 95 | 96 | 🚧 Deployment in progress for git commit SHA: ${{ steps.find-pull-request.outputs.sha }} 97 | 98 | - name: Update Jupyter Book Preview comment 99 | if: | 100 | github.event.workflow_run.conclusion == 'success' 101 | && steps.fc.outputs.comment-id != '' 102 | uses: peter-evans/create-or-update-comment@v1 103 | with: 104 | comment-id: ${{ steps.fc.outputs.comment-id }} 105 | edit-mode: replace 106 | body: | 107 | ${{ env.comment_message }} 108 | 109 | 📚 Git commit SHA: ${{ steps.find-pull-request.outputs.sha }} 110 | ✅ Deployment Preview URL: https://github.com/ 111 | --------------------------------------------------------------------------------