Skip to content

Commit

Permalink
ci: Add build-web workflow (#2181)
Browse files Browse the repository at this point in the history
Will hopefully prevent issues like #2144, sorry for not having this earlier
  • Loading branch information
max-sixty authored Mar 14, 2023
1 parent 1ac5f97 commit d08b13a
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 78 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build-web.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: build-web

on:
pull_request:
paths:
- "web/**"
- ".github/workflows/build-web.yaml"
workflow_call:

jobs:
build-web:
runs-on: ubuntu-latest

# Skip running workflow on forks. Checking the repository owner still allows
# this to be run on PRs, and then below we disable it from attempting to
# publish.
if: github.repository_owner == 'prql'

steps:
- name: 📂 Checkout code
uses: actions/checkout@v3

# Website requires hugo
- name: Setup hugo
uses: peaceiris/actions-hugo@v2.6.0

# Book setup, duplicated from `pull-request.yaml`
- uses: baptiste0928/cargo-install@next
with:
crate: mdbook
- uses: baptiste0928/cargo-install@next
with:
crate: mdbook-footnote
- uses: baptiste0928/cargo-install@next
with:
crate: mdbook-admonish

- name: 💰 Cache
uses: Swatinem/rust-cache@v2
with:
save-if:
${{ github.ref == 'refs/heads/web' || github.ref ==
'refs/heads/main' }}

- uses: ./.github/actions/build-prql-js

- uses: arduino/setup-task@v1
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

- name: 🕷️ Build website
run: task build-web

- uses: actions/upload-pages-artifact@v1.0.7
with:
path: web/website/public/
68 changes: 14 additions & 54 deletions .github/workflows/publish-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,71 +11,31 @@ on:
# Called by pull-request when specifically requested
workflow_call:

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write
id-token: write

jobs:
build-web:
runs-on: ubuntu-latest

# Skip running workflow on forks. Checking the repository owner still allows
# this to be run on PRs, and then below we disable it from attempting to
# publish.
if: github.repository_owner == 'prql'

steps:
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3

- name: 📂 Checkout code
uses: actions/checkout@v3

# Website setup
- name: Setup hugo
uses: peaceiris/actions-hugo@v2.6.0

# Book setup, duplicated from `pull-request.yaml`
- uses: baptiste0928/cargo-install@next
with:
crate: mdbook
- uses: baptiste0928/cargo-install@next
with:
crate: mdbook-footnote
- uses: baptiste0928/cargo-install@next
with:
crate: mdbook-admonish
- name: 💰 Cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/web' }}

- uses: ./.github/actions/build-prql-js

- uses: arduino/setup-task@v1
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

- name: 🕷️ Build website
run: task build-web

- uses: actions/upload-pages-artifact@v1.0.7
with:
path: web/website/public/
uses: ./.github/workflows/build-web.yaml

deploy-web:
needs: build-web
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Don't attempt to publish if on a fork, including a PR.
if: "!github.event.pull_request.head.repo.fork"

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1.2.5
25 changes: 1 addition & 24 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,8 @@ jobs:
os: ${{ matrix.os }}
target_option: ${{ matrix.target_option }}

test-book:
runs-on: ubuntu-latest
steps:
- name: 📂 Checkout code
uses: actions/checkout@v3
# Duplicated in `publish-web.yaml`
- uses: baptiste0928/cargo-install@next
with:
crate: mdbook
- uses: baptiste0928/cargo-install@next
with:
crate: mdbook-footnote
- uses: baptiste0928/cargo-install@next
with:
crate: mdbook-admonish
- name: 💰 Cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: 🔨 Build
run: mdbook build
working-directory: web/book/

# Run Mac & Windows & bindings' other tests on a `pr-test-all` label or a `!`
# (meanting a breaking change) in the PR title. (We also run on other
# (meaning a breaking change) in the PR title. (We also run on other
# conditions defined in `test-all.yaml`; the conditions defined here aren't
# possible to use as conditions for running a workflow, only a job, so we use
# this approach.)
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ concurrency:
cancel-in-progress: true

jobs:
build-web:
uses: ./.github/workflows/build-web.yaml

test-rust:
strategy:
matrix:
Expand Down

0 comments on commit d08b13a

Please sign in to comment.