Skip to content

Commit

Permalink
ci: publish review docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mfal committed Jan 30, 2024
1 parent e5bdd22 commit 56c1ce8
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/coverage-badges.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "coverage-badges"
name: "Create Jest coverage bages"
on:
push:
branches:
Expand Down Expand Up @@ -32,4 +32,4 @@ jobs:
coverage-summary-path: ./packages/components/coverage/coverage-summary.json

- name: Push badges branch
run: git push origin badges
run: git push origin badges
3 changes: 2 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: "coverage"
name: "Build Jest coverage report"

on:
pull_request:
branches:
Expand Down
32 changes: 22 additions & 10 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Publish docs
name: Publish docs to GitHub Pages

on:
push:
branches:
Expand All @@ -15,30 +16,41 @@ concurrency:

jobs:
build:
env:
NEXT_BASE_PATH: "/flow"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Checkout ⬇️
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
- name: Setup Node 🎛️
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
registry-url: "https://registry.npmjs.org"

- run: yarn install --immutable
- uses: nrwl/nx-set-shas@v4
- if: github.ref != 'refs/heads/main'
- name: Yarn Install 📦️
run: yarn install --immutable

- name: Setup NX 1/2 🎛️
uses: nrwl/nx-set-shas@v4

- name: Setup NX 2/2 🎛
if: github.ref != 'refs/heads/main'
run: git branch --track main origin/main
- run: yarn nx affected -t build --parallel=3

- uses: actions/configure-pages@v4
- name: Build 🔨
run: yarn nx affected -t build --parallel=3

- name: Configure GitHub pages ⚙️
uses: actions/configure-pages@v4
with:
static_site_generator: next

- name: Upload artifact
- name: Upload GitHub Pages artifact ⬆️
uses: actions/upload-pages-artifact@v3
with:
path: packages/docs/out
Expand Down
99 changes: 99 additions & 0 deletions .github/workflows/publish-review-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Publish review docs

on:
push:
branches-ignore:
- main

permissions:
contents: read

concurrency:
group: "pages"
cancel-in-progress: false

env:
NEXT_BASE_PATH: "/docs/${{ github.ref_name }}"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout ⬇️
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node 🎛️
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
registry-url: "https://registry.npmjs.org"

- name: Yarn Install 📦️
run: yarn install --immutable

- name: Setup NX 1/2 🎛️
uses: nrwl/nx-set-shas@v4

- name: Setup NX 2/2 🎛
if: github.ref != 'refs/heads/main'
run: git branch --track main origin/main

- name: Build 🔨
run: yarn nx affected -t build --parallel=3

- name: Upload artifact ⬆️
uses: actions/upload-artifact@v4
with:
path: packages/docs/out
name: site

deploy:
environment:
name: github-pages-preview
url: https://mittwald.github.io/flow-previews/${{ github.ref_name }}

runs-on: ubuntu-latest
needs: build

steps:
- name: Download the artifact ⬇️
uses: actions/download-artifact@v4
with:
name: site
path: docs

- name: Upload files to GitHub Pages 🚀
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.PUBLISH_PAT }}
with:
source-directory: "docs"
destination-github-username: "mittwald"
destination-repository-name: "flow-previews"
target-branch: main
target-directory: "${{ env.NEXT_BASE_PATH }}"

- name: Output the URL
run: echo "${{ job.environment.url }}"

comment-on-pull-request:
runs-on: ubuntu-latest
permissions:
pull-requests: write
# Only run if a comment was not already made
if:
${{ github.event_name == 'pull_request' && github.event.action == 'opened'
&& !contains(github.event.pull_request.body, 'A [live preview]') }}
steps:
- uses: actions/github-script@v5
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'A [live preview](${{ job.environment.url }}) is being deployed!<br><br>Please note that it may take a few seconds for GitHub Pages to build and deploy.'
})
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish
name: Publish packages to NPM
on:
pull_request:
types: [closed]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Run tests
on:
push:
branches:
Expand Down
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"affected": {
"defaultBase": "master"
"defaultBase": "main"
},
"namedInputs": {
"src": ["{projectRoot}/{src,dev}/**/!(*.test).*"],
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import remarkMdxFrontmatter from "remark-mdx-frontmatter";
/** @type {import("next").NextConfig} */
const nextConfig = {
output: "export",
basePath: "/flow",
basePath: process.env.NEXT_BASE_PATH ?? "",
pageExtensions: ["js", "jsx", "mdx", "ts", "tsx", "example"],
webpack: (config, _) => {
config.module.rules.push({
Expand Down

0 comments on commit 56c1ce8

Please sign in to comment.