Build docs as CI artifacts #1990
Workflow file for this run
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: CI | |
on: | |
pull_request: | |
push: | |
env: | |
MIX_ENV: test | |
jobs: | |
elixir_js_and_lint: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
include: | |
- elixir: "1.17" | |
otp: "27" | |
node: 18.x | |
steps: | |
- uses: actions/checkout@v3 | |
# Setup Node | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{matrix.node}} | |
- name: Cache npm dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('asssets/package-lock.json') }} | |
- run: npm ci --prefix assets | |
# Setup Elixir | |
- uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ matrix.otp }} | |
elixir-version: ${{ matrix.elixir }} | |
- run: mix deps.get | |
# Generate docs artifact | |
- name: Generate docs | |
run: | | |
mix build | |
test -f doc/index.html && echo "doc/index.html exists." | |
test -f doc/ExDoc.epub && echo "doc/ExDoc.epub exists." | |
- name: Upload docs | |
uses: actions/upload-artifact@v4 | |
id: docs-upload | |
with: | |
name: docs | |
path: doc/ | |
overwrite: true | |
- name: Build update | |
uses: actions/github-script@v7 | |
if: github.event_name == 'pull_request' | |
env: | |
ARTIFACT_ID: ${{ steps.docs-upload.outputs.artifact-id }} | |
with: | |
script: | | |
const artifactUrl = '$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/artifacts/$ARTIFACT_ID'; | |
const commentBody = `<!-- build-artifact-comment -->📦 Build artifacts are ready: ${artifactUrl}`; | |
const comments = await github.rest.issues.listComments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
}); | |
const botComment = comments.data.find(comment => | |
comment.body.includes('<!-- build-artifact-comment -->') | |
); | |
if (botComment) { | |
await github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: botComment.id, | |
body: commentBody | |
}); | |
} else { | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: commentBody | |
}); | |
} | |
# Test Elixir | |
- run: mix format --check-formatted | |
- run: mix deps.unlock --check-unused | |
- run: mix compile --force --warnings-as-errors | |
- run: mix test | |
- run: test/prerelease.sh | |
# Test JS | |
- run: npm run lint --prefix assets | |
- name: npm run test --prefix assets | |
run: | | |
sudo apt-get install xvfb | |
xvfb-run --auto-servernum npm run test --prefix assets | |
env: | |
CI: true | |
# Push updated assets if all good | |
- name: Push updated assets | |
if: github.ref_name == 'main' | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Update assets | |
file_pattern: formatters | |
elixir: | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Test very old Elixir and Erlang | |
- elixir: "1.14" | |
otp: "25" | |
# Test Erlang without -doc attribute support | |
- elixir: "1.16" | |
otp: "26" | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ matrix.otp }} | |
elixir-version: ${{ matrix.elixir }} | |
- run: mix deps.get | |
- run: mix test | |
- run: test/prerelease.sh |