fixes for makeshift gif fix #14
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: Examples | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- main | |
paths: | |
- 'src/**' | |
- 'examples/src/**' | |
- '.github/workflows/Example.yml' | |
- 'Project.toml' | |
jobs: | |
sync-files: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-latest] # , ubuntu-latest] | |
file-name: [advanced_hybrid_ME, modelica_conference_2021, simple_hybrid_CS, simple_hybrid_ME, mdpi_2022, juliacon_2023] | |
julia-version: ['1.8'] | |
julia-arch: [x64] | |
experimental: [false] | |
steps: | |
- name: "Check out repository" | |
uses: actions/checkout@v3 | |
- name: "Set up Julia" | |
uses: julia-actions/setup-julia@v1 | |
with: | |
version: ${{ matrix.julia-version }} | |
arch: ${{ matrix.julia-arch }} | |
- name: "Install dependencies" | |
run: julia --project=examples/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' | |
- name: "Install packages" | |
run: pip install jupyter nbconvert | |
- name: "Execute and synchronize all files" | |
env: | |
FILE: examples/src/${{ matrix.file-name }}.ipynb | |
run: | | |
jupyter nbconvert --ExecutePreprocessor.kernel_name="julia-1.8" --to notebook --inplace --execute ${{ env.FILE }} | |
jupyter nbconvert --to script ${{ env.FILE }} | |
jupyter nbconvert --to markdown ${{ env.FILE }} | |
- name: "Fix GIF" | |
run: | | |
if ("${{ matrix.file-name }}" -eq "juliacon_2023") | |
{ | |
echo "starting the mess" | |
$env:Path += ";C:\Program Files\Git\usr\bin" | |
sed -i -E 's~(<img src=\"data:image\/gif;base64,[[:alpha:],[:digit:],\/,+,=]*\" \/>)~\\\`\\\`\\\`@raw html\n\1\n\\\`\\\`\\\`~g' examples/src/${{ matrix.file-name }}.md | |
echo "mess finished" | |
} | |
- name: Archive examples artifacts | |
if: success() && matrix.os == 'windows-latest' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: examples | |
path: examples/src/${{ matrix.file-name }}* | |
auto-commit: | |
needs: sync-files | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Download examples | |
uses: actions/download-artifact@v3 | |
with: | |
name: examples | |
path: examples/src/ | |
- name: auto-commit | |
env: | |
CI_COMMIT_MESSAGE: Jupyter nbconvert synch - modified, paired .ipynb files | |
CI_COMMIT_AUTHOR: github-actions[bot] | |
EXAMPLES_PATH: examples/src | |
# Fetch all and clear the stash list. Include all files from the examples/src folder to the stash and switch the branch. | |
# Reset the branch and remove all current files in the examples/src folder. | |
# Checkout the last stash to restore the new notebooks and apply the stash index to restore all other new files in the folder. | |
run: | | |
git fetch --all | |
git stash clear | |
git stash --include-untracked -- ${{ env.EXAMPLES_PATH }} | |
git switch examples | |
git reset --hard origin/examples | |
rm -rf ${{ env.EXAMPLES_PATH }} | |
git checkout stash -f -- ${{ env.EXAMPLES_PATH }} | |
git stash apply --index | |
git stash drop | |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}" | |
git config --global user.email "${{ env.CI_COMMIT_AUTHOR }}@users.noreply.github.com" | |
git config --global core.autocrlf false | |
git add ${{ env.EXAMPLES_PATH }} | |
git commit -m "${{ env.CI_COMMIT_MESSAGE }}" | |
git push origin examples | |
call-docu: | |
needs: auto-commit | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
# Trigger an repoisitory dispath event | |
- name: Repository Dispatch | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
event-type: trigger-docu |