Skip to content

Commit

Permalink
ci: split gh-pages from ci jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
storopoli committed Jan 21, 2024
1 parent fb0c3bb commit ce92cfc
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 23 deletions.
41 changes: 18 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,36 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- run: |
- name: Add release date to index.html
run: |
VERSION="$(date +'%Y-%m-%d %H:%M')"
sed --in-place "s/<VERSION>/$VERSION/g" index.html
shell: bash

- uses: mymindstorm/setup-emsdk@v13
- name: Setup emscripten SDK
uses: mymindstorm/setup-emsdk@v13

- uses: dtolnay/rust-toolchain@v1
- name: Setup Stable Rust with emscripten target
uses: dtolnay/rust-toolchain@v1
with:
target: 'wasm32-unknown-emscripten'
toolchain: 'stable'

- run: cargo test
- name: Rust cache
uses: Swatinem/rust-cache@v2

- run: ./script/build.sh
- name: Test
run: cargo test

- name: Build site
run: ./script/build.sh

- uses: actions/upload-pages-artifact@v3
if: ${{ github.event_name != 'pull_request' }}
- name: Upload arfifact
uses: actions/upload-pages-artifact@v3
if: ${{ github.event_name == 'pull_request' }}
with:
path: 'public/'
retention-days: '1'

deploy:
# Separate step to keep the permissions separated.
needs: build
if: ${{ github.event_name != 'pull_request' }}
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- id: deployment
uses: actions/deploy-pages@v4
51 changes: 51 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: ci

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Add release date to index.html
run: |
VERSION="$(date +'%Y-%m-%d %H:%M')"
sed --in-place "s/<VERSION>/$VERSION/g" index.html
shell: bash

- name: Setup emscripten SDK
uses: mymindstorm/setup-emsdk@v13

- name: Setup Stable Rust with emscripten target
uses: dtolnay/rust-toolchain@v1
with:
target: 'wasm32-unknown-emscripten'
toolchain: 'stable'

- name: Rust cache
uses: Swatinem/rust-cache@v2

- name: Build site
run: ./script/build.sh

deploy:
# Separate step to keep the permissions separated.
needs: build
permissions:
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment.
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from source.
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

0 comments on commit ce92cfc

Please sign in to comment.