Skip to content

Commit

Permalink
ci: support multiple pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Randoooom committed Mar 17, 2024
1 parent 01a165f commit f170b92
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 19 deletions.
62 changes: 44 additions & 18 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Nightly

on:
workflow_dispatch:
schedule:
- cron: '0 0 */2 * *'
push:
branches:
- main
Expand Down Expand Up @@ -145,40 +147,64 @@ jobs:
command: install
args: cargo-make

- name: Determine current pages artifact
id: determine_pages_artifact
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data } = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
branch: "main",
status: "success",
per_page: 1
});
core.setOutput("last_run", data.workflow_runs[0].id);
- name: Download current pages artifact
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.determine_pages_artifact.outputs.last_run }}
name: github-pages
path: ./

- name: Extract pages artifact
run: mkdir pages/ && tar -xvf artifact.tar -C pages/

- name: Build docs
uses: actions-rs/cargo@v1
with:
command: make
args: docs_build

- name: Archive artifact
- name: Prefix docs
run: mkdir -p pages/nightly/ && mv -f target/docs/ pages/nightly/docs/

- name: Fix permissions
run: |
tar \
--dereference --hard-dereference \
-cvf "$RUNNER_TEMP/pages.tar" \
docs/
- name: Upload artifact
id: upload-artifact
uses: actions/upload-artifact@v4
with:
name: pages
path: ${{ runner.temp }}/pages.tar
retention-days: 1
if-no-files-found: error
chmod -c -R +rX "pages/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: pages/
retention-days: 3

deploy-docs:
deploy-pages:
needs: [ build-docs, test ]
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}/nightly
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to pages
id: deployment
uses: actions/deploy-pages@v4
with:
artifact_name: "pages"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ docs/
# nvim config
.sqllsrc.json

pages/
2 changes: 1 addition & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ args = [
[tasks.docs_build]
dependencies = ["docs_lint"]
command = "npx"
args = ["redocly", "build-docs", "target/openapi.yaml", "-o", "docs/rest/index.html"]
args = ["redocly", "build-docs", "target/openapi.yaml", "-o", "target/docs/http/index.html"]

# bindings

Expand Down

0 comments on commit f170b92

Please sign in to comment.