Skip to content

corrections ch05

corrections ch05 #132

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