main.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # CLOUDFLARE_API_KEY="XXXX"
  2. # CLOUDFLARE_ZONE="XXXX"
  3. name: Build
  4. on:
  5. schedule:
  6. - cron: "0 0 * * 1"
  7. push:
  8. branches:
  9. - master
  10. jobs:
  11. build:
  12. runs-on: ubuntu-18.04
  13. container:
  14. image: jmonkeyengine/buildenv-jme3:hugo
  15. steps:
  16. - name: Clone master
  17. run: |
  18. git config --global user.name "GithubActions"
  19. git config --global user.email "[email protected]"
  20. git clone --single-branch --depth 1 --recurse-submodules --branch master https://github.com/${GITHUB_REPOSITORY}.git project
  21. - name: Clone gh-pages
  22. run: |
  23. git config --global user.name "GithubActions"
  24. git config --global user.email "[email protected]"
  25. git clone --no-checkout --single-branch --branch gh-pages https://github.com/${GITHUB_REPOSITORY}.git generated
  26. cd generated
  27. git reset --hard `git rev-list --max-parents=0 HEAD`
  28. cd ..
  29. - name: Build
  30. run: |
  31. cd project
  32. chmod +x ./make.sh
  33. NO_CONTAINER=1 HEADLESS=1 ./make.sh
  34. mkdir -p public
  35. echo "1" > public/.nojekyll
  36. - name: Deploy
  37. shell: bash
  38. run: |
  39. shopt -s dotglob
  40. cp -Rf project/public/* generated/
  41. cd generated
  42. git add .
  43. git commit -m "Update data - `date`"
  44. header=$(echo -n "ad-m:${{ secrets.GITHUB_TOKEN }}" | base64)
  45. set +e
  46. (git -c http.extraheader="AUTHORIZATION: basic $header" push origin gh-pages --force )
  47. - name: Purge Cloudflare Cache
  48. shell: bash
  49. run: |
  50. curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE }}/purge_cache" \
  51. -H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_KEY }}" \
  52. -H "Content-Type: application/json" --data '{"purge_everything":true}'