|
| 1 | +name: Build and deploy site |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + schedule: |
| 7 | + - cron: '0 */6 * * *' |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Fetch docs from tracked repos |
| 20 | + run: | |
| 21 | + fetch_file() { |
| 22 | + local owner="$1" repo="$2" src="$3" dst="$4" title="$5" summary="$6" |
| 23 | + echo "Fetching $owner/$repo/$src -> $dst" |
| 24 | + mkdir -p "$(dirname "$dst")" |
| 25 | + curl -sfL "https://raw.githubusercontent.com/$owner/$repo/HEAD/$src" -o "$dst" |
| 26 | + if ! head -1 "$dst" | grep -q '^---'; then |
| 27 | + tmp=$(mktemp) |
| 28 | + cat > "$tmp" <<FRONT |
| 29 | + --- |
| 30 | + title: "$title" |
| 31 | + summary: "$summary" |
| 32 | + authors: ["The OCurrent Team"] |
| 33 | + --- |
| 34 | +
|
| 35 | + FRONT |
| 36 | + cat "$dst" >> "$tmp" |
| 37 | + mv "$tmp" "$dst" |
| 38 | + fi |
| 39 | + } |
| 40 | +
|
| 41 | + # ocurrent/ocurrent |
| 42 | + fetch_file ocurrent ocurrent doc/example_pipelines.md content/docs/ocurrent/example_pipelines.md "Example pipelines" "Some example pipelines in OCurrent" |
| 43 | + fetch_file ocurrent ocurrent doc/internals.md content/docs/ocurrent/internals.md "Internal overview" "How OCurrent work under the hood" |
| 44 | + fetch_file ocurrent ocurrent doc/writing_plugins.md content/docs/ocurrent/writing_plugins.md "Write your own plugin" "How to write your own plugin in OCurrent" |
| 45 | + fetch_file ocurrent ocurrent doc/disk_cache.md content/docs/ocurrent/disk_cache.md "The build cache" "How the build cache is stored" |
| 46 | +
|
| 47 | + # ocurrent/ocaml-multicore-ci |
| 48 | + fetch_file ocurrent ocaml-multicore-ci README.md content/docs/ocaml-multicore-ci/readme.md "Readme" "What is and how to run ocaml-multicore-ci." |
| 49 | +
|
| 50 | + # ocurrent/ocaml-ci |
| 51 | + fetch_file ocurrent ocaml-ci README.md content/docs/ocaml-ci/README.md "Readme" "What is OCaml CI and how to use it." |
| 52 | + fetch_file ocurrent ocaml-ci doc/dev.md content/docs/ocaml-ci/dev.md "Development notes" "How to setup a development environment for OCaml CI." |
| 53 | + fetch_file ocurrent ocaml-ci doc/docker-deployment.md content/docs/ocaml-ci/docker-deployment.md "Deploy on Docker" "How to deploy your own CI with Docker." |
| 54 | +
|
| 55 | + # ocurrent/opam-repo-ci |
| 56 | + fetch_file ocurrent opam-repo-ci README.md content/docs/opam-repo-ci/README.md "Readme" "Informations about what is opam-repo-ci." |
| 57 | +
|
| 58 | + # ocurrent/opam-health-check |
| 59 | + fetch_file ocurrent opam-health-check README.md content/docs/opam-health-check/README.md "Readme" "What is the purpose of opam-health-check and how to use it." |
| 60 | +
|
| 61 | + # ocurrent/ocaml-docs-ci |
| 62 | + fetch_file ocurrent ocaml-docs-ci README.md content/docs/ocaml-docs-ci/README.md "Readme" "How OCaml Docs CI works." |
| 63 | +
|
| 64 | + # ocurrent/docker-base-images |
| 65 | + fetch_file ocurrent docker-base-images README.md content/docs/docker-base-images/README.md "Readme" "Description about what is the purpose of docker-base-images." |
| 66 | +
|
| 67 | + # ocurrent/ocurrent-deployer |
| 68 | + fetch_file ocurrent ocurrent-deployer README.md content/docs/ocurrent-deployer/README.md "Readme" "Explanations about ocurrent-deployer." |
| 69 | + fetch_file ocurrent ocurrent-deployer VM-host.md content/docs/ocurrent-deployer/VM-host.md "VM Host Machine" "How to setup a VM to use your own deployer." |
| 70 | +
|
| 71 | + - name: Generate index pages |
| 72 | + run: | |
| 73 | + generate_index() { |
| 74 | + local title="$1" description="$2" dst="$3" |
| 75 | + mkdir -p "$dst" |
| 76 | + cat > "$dst/_index.md" <<FRONT |
| 77 | + --- |
| 78 | + title: "$title" |
| 79 | + description: "$description" |
| 80 | + --- |
| 81 | + FRONT |
| 82 | + } |
| 83 | +
|
| 84 | + generate_index "OCurrent" "List of OCurrent documents" content/docs/ocurrent |
| 85 | + generate_index "OCaml Multicore CI" "List of OCaml Multicore CI documents" content/docs/ocaml-multicore-ci |
| 86 | + generate_index "OCaml CI" "Material about OCaml CI" content/docs/ocaml-ci |
| 87 | + generate_index "Opam Repo CI" "List of materials about Opam Repo CI" content/docs/opam-repo-ci |
| 88 | + generate_index "Opam Health Check" "List of opam-health-check documents" content/docs/opam-health-check |
| 89 | + generate_index "OCaml Docs CI" "Various materials about ocaml-docs-ci" content/docs/ocaml-docs-ci |
| 90 | + generate_index "Docker Base Images" "List of docker-base-images resources" content/docs/docker-base-images |
| 91 | + generate_index "OCurrent Deployer" "Resources to work with ocurrent-deployer" content/docs/ocurrent-deployer |
| 92 | +
|
| 93 | + - name: Setup Hugo |
| 94 | + uses: peaceiris/actions-hugo@v3 |
| 95 | + with: |
| 96 | + hugo-version: '0.139.0' |
| 97 | + extended: true |
| 98 | + |
| 99 | + - name: Build |
| 100 | + run: | |
| 101 | + hugo -d public --logLevel info |
| 102 | + echo "www.ocurrent.org" > public/CNAME |
| 103 | +
|
| 104 | + - name: Deploy to gh-pages branch |
| 105 | + run: | |
| 106 | + cd public |
| 107 | + git init |
| 108 | + git config user.name "GitHub Actions" |
| 109 | + git config user.email "actions@github.com" |
| 110 | + git checkout -b gh-pages |
| 111 | + git add . |
| 112 | + git commit -m "Deploy $(date -u +%Y-%m-%dT%H:%M:%SZ)" |
| 113 | + git push -f "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git" gh-pages |
0 commit comments