|
| 1 | +# create a documentation web site for GSAS-II from four sources |
| 2 | +# * HTML tutorials are simply copied |
| 3 | +# * markdown tutorials (in ./MDtutorials) are formatted with pandoc and are copied over |
| 4 | +# * sphinx is used to generate HTML from files in ./webdocs |
| 5 | + |
| 6 | +# Also the tutorials.html file and the */data/index.html files are |
| 7 | +# created by running scripts/makeGitTutorial |
| 8 | + |
| 9 | +# this is a development version that creates draft help pages from the MDhelp directory |
| 10 | +# For now |
| 11 | +# * HTML help files are copied over from the GSAS-II sources |
| 12 | +# Eventually, the help files generated here need to get into the GSASII/help |
| 13 | +# directory |
| 14 | + |
| 15 | +name: build GSAS-II web site w/test MD Help |
| 16 | + |
| 17 | +#on: [workflow_dispatch] |
| 18 | +on: |
| 19 | + push: |
| 20 | + branches: |
| 21 | + - "main" |
| 22 | + workflow_dispatch: |
| 23 | + |
| 24 | +permissions: |
| 25 | + contents: write |
| 26 | + id-token: write |
| 27 | + pages: write |
| 28 | + |
| 29 | +jobs: |
| 30 | + build: # Build web pages |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + |
| 34 | + - name: Python setup |
| 35 | + uses: actions/setup-python@v3 |
| 36 | + - name: Sphinx setup |
| 37 | + run: | |
| 38 | + pip install sphinx sphinx_readable_theme |
| 39 | + - name: pandoc setup |
| 40 | + uses: pandoc/actions/setup@v1 |
| 41 | + |
| 42 | + # MD help stuff |
| 43 | + - name: install debian chrome |
| 44 | + run: | |
| 45 | + set -ex |
| 46 | + wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb |
| 47 | + sudo apt install ./google-chrome-stable_current_amd64.deb |
| 48 | + |
| 49 | +# - name: test newly-installed chrome |
| 50 | +# run: | |
| 51 | +# which google-chrome-stable |
| 52 | +# google-chrome-stable --version |
| 53 | +# /usr/bin/google-chrome-stable --headless --disable-gpu --dump-dom https://google.com |
| 54 | + - name: mkdocs setup |
| 55 | + run: | |
| 56 | + pip install mkdocs mkdocs-material python-markdown-math mkdocs-static-i18n |
| 57 | + pip install mkdocs-to-pdf pymdown-extensions |
| 58 | +
|
| 59 | + - name: Checkout |
| 60 | + uses: actions/checkout@v4 |
| 61 | + |
| 62 | + # MD help stuff |
| 63 | + - name: convert MDhelp |
| 64 | + run: | |
| 65 | + cd MDhelp |
| 66 | + mkdocs build |
| 67 | + cp -vr site ../help_test |
| 68 | + ENABLE_PDF_EXPORT=1 mkdocs build |
| 69 | + mv site/GSASII-help.pdf ../docs/ |
| 70 | + # create an anchor index |
| 71 | + python findMDanchors.py |
| 72 | + cp -vr site ../help_test |
| 73 | + |
| 74 | + # - name: Upload help artifact # creates zip file with website contents |
| 75 | + # uses: actions/upload-pages-artifact@v3 |
| 76 | + # with: |
| 77 | + # path: MDhelp/site |
| 78 | + # name: MDhelp |
| 79 | + # retention-days: 1 |
| 80 | + |
| 81 | + - name: Get tutorials index from source code |
| 82 | + run: | |
| 83 | + curl -L https://github.com/AdvancedPhotonSource/GSAS-II/raw/master/GSASII/tutorialIndex.py -o scripts/tutorialIndex.py |
| 84 | +
|
| 85 | + - name: convert tutorials |
| 86 | + run: | |
| 87 | + cd MDtutorials |
| 88 | + for path in ./*; do |
| 89 | + [ -d "${path}" ] || continue # skip if not a directory |
| 90 | + dirname="$(basename "${path}")" |
| 91 | + dest="../${dirname}" |
| 92 | + mkdir -pv ${dest} |
| 93 | + [ ! -d "${path}/data" ] || cp -r "${path}/data" ${dest}/ |
| 94 | + [ ! -d "${path}/imgs" ] || cp -r "${path}/imgs" ${dest}/ |
| 95 | + cp tutorial.css ${dest} |
| 96 | + for fil in $dirname/*.md; do |
| 97 | + outfile="${dest}/$(basename "${fil%.md}.html")" |
| 98 | + echo "creating $outfile from $fil" |
| 99 | + pandoc --standalone ${fil} --css tutorial.css -o ${outfile} |
| 100 | + sed -i "s/<figure>/<BR clear=all><figure>/g" ${outfile} |
| 101 | + done |
| 102 | + git add ${dest} |
| 103 | + done |
| 104 | + cd .. |
| 105 | + |
| 106 | + - name: build tutorials index |
| 107 | + run: | |
| 108 | + cd scripts |
| 109 | + python makeGitTutorial.py .. |
| 110 | +
|
| 111 | +# - name: Note changed files |
| 112 | +# run: | |
| 113 | +# git add tutorials.html |
| 114 | +# git add */data/index.html |
| 115 | +# git status |
| 116 | +# git commit -m"changes from automated build of tutorials" |
| 117 | +# - name: Push changes |
| 118 | +# uses: ad-m/github-push-action@master |
| 119 | + |
| 120 | + - name: Sphinx build |
| 121 | + run: | |
| 122 | + sphinx-build webdocs . # place output into root dir |
| 123 | + cp webdocs/_static/fix.css _static/fix.css # should be done by sphinx |
| 124 | +
|
| 125 | + # to be replaced by MD help stuff |
| 126 | + # get the help pages from the GSAS-II sources into the web site |
| 127 | + - name: Get GSAS-II |
| 128 | + run: | |
| 129 | + git clone --depth 1 https://github.com/AdvancedPhotonSource/GSAS-II.git _gsas2 |
| 130 | + - name: move help into site |
| 131 | + run: | |
| 132 | + mv _gsas2/GSASII/help ./help |
| 133 | + - name: Get rid of the rest of the GSAS-II files & other stuff not needed on web |
| 134 | + run: | |
| 135 | + rm -rf _gsas2 webdocs scripts MDtutorials MDhelp |
| 136 | + |
| 137 | + - name: Upload artifact # creates zip file with website contents |
| 138 | + uses: actions/upload-pages-artifact@v3 |
| 139 | + with: |
| 140 | + path: . |
| 141 | + name: github-pages |
| 142 | + retention-days: 1 |
| 143 | + |
| 144 | + deploy: # Deployment of web pages to GitHub pages |
| 145 | + needs: build |
| 146 | + permissions: |
| 147 | + pages: write |
| 148 | + id-token: write |
| 149 | + environment: |
| 150 | + name: github-pages |
| 151 | + url: ${{ steps.deployment.outputs.page_url }} |
| 152 | + runs-on: ubuntu-latest |
| 153 | + |
| 154 | + steps: |
| 155 | + - name: Deploy to GitHub Pages |
| 156 | + id: deployment |
| 157 | + uses: actions/deploy-pages@v4 |
| 158 | + with: |
| 159 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 160 | + artifact_name: github-pages |
0 commit comments