corrections ch06 #133
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
on: | |
push: | |
branches: | |
[main] | |
name: Prepare-book-package | |
jobs: | |
package: | |
name: Convert | |
runs-on: ubuntu-latest | |
container: ghcr.io/geocompx/docker:python | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
if: contains(github.event.head_commit.message, 'update book package') | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Convert | |
run: | | |
pip3 install jupytext | |
# Convert .qmd files to .ipynb and .py files, see convert.sh | |
./convert.sh | |
- name: Copy | |
env: | |
SRC_FOLDER_PATH1: 'ipynb' | |
SRC_FOLDER_PATH2: 'data' | |
SRC_FOLDER_PATH3: 'output' | |
TARGET_BRANCH: 'geocompy' | |
run: | | |
git config --global --add safe.directory /__w/geocompy/geocompy | |
files1=$(find $SRC_FOLDER_PATH1 -type f) # get the file list | |
files2=$(find $SRC_FOLDER_PATH2 -type f) # get the file list | |
files3=$(find $SRC_FOLDER_PATH3 -type f) # get the file list | |
git config --global user.name 'GitHub Action' | |
git config --global user.email '[email protected]' | |
git add *.ipynb | |
git add *.py | |
git commit -m 'Re-build .ipynb and .py files' || echo "No changes to commit" | |
git fetch # fetch branches | |
git checkout $TARGET_BRANCH # checkout to your branch | |
git checkout ${GITHUB_REF##*/} -- $files1 # copy files from the source branch | |
git mv -f ipynb/*.ipynb . # move files from ipynb to root dir | |
git checkout ${GITHUB_REF##*/} -- $files2 # copy files from the source branch | |
git checkout ${GITHUB_REF##*/} -- $files3 # copy files from the source branch | |
git add -A | |
git diff-index --quiet HEAD || git commit -am "deploy files" # commit to the repository (ignore if no modification) | |
git push origin $TARGET_BRANCH # push to remote branch |