-
Notifications
You must be signed in to change notification settings - Fork 5
65 lines (53 loc) · 1.81 KB
/
publish-docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
on:
workflow_call:
inputs:
elixir_version:
required: true
type: string
otp_version:
required: true
type: string
permissions:
contents: write
jobs:
publish-docs:
name: Publish
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Setup Erlang & Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ inputs.elixir_version }}
otp-version: ${{ inputs.otp_version }}
# Caching
- name: Dependencies cache
uses: actions/cache/restore@v4
with:
path: deps
key: ${{ runner.os }}-deps-${{ hashFiles('mix.lock') }}
- name: Build cache
uses: actions/cache/restore@v4
with:
path: _build
key: ${{ runner.os }}-build-dev-${{inputs.elixir_version}}-${{inputs.otp_version}}-${{ hashFiles('mix.lock') }}
# Run
- name: Override version
run: echo '0.0.0' > VERSION
- name: Generate docs
run: mix docs
- name: Replace source links
run: find "./doc" -type f -name "*.html" -exec sed -i 's/\/blob\/v0.0.0\//\/blob\/${{ github.sha }}\//g' {} +
- name: Replace package version
run: find "./doc" -type f -name "*.html" -exec sed -i 's/v0.0.0/main/g' {} +
- name: Add version list
run: |
curl -sS https://hex.pm/api/packages/dx \
| jq -rc '[.releases | .[] | select(.has_docs) | {"latest": false, "version": ("v" + .version), "url": ("https://hexdocs.pm/dx/" + .version)}]' \
| (echo -n 'var versionNodes = [{"latest":false,"version":"main",url:"https://elixir-dx.github.io/dx"},{"latest":true' && (cat | cut -c17-)) \
| tee $GITHUB_WORKSPACE/doc/docs_config.js
- name: Push docs
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: doc