Skip to content

Commit

Permalink
reusable + caller
Browse files Browse the repository at this point in the history
  • Loading branch information
abernier committed Aug 9, 2024
1 parent c8c7891 commit 801854b
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 21 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Reusable pmndrs/docs workflow

on:
workflow_call:
inputs:
mdx:
required: true
type: string
libname:
required: true
type: string

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

# container:
# image: ghcr.io/pmndrs/playwright:main
# credentials:
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4
- id: configurepages
uses: actions/configure-pages@v5
- run: |
docker run --rm --init \
-v "$MDX":/app/docs \
-e BASE_PATH \
-e DIST_DIR=docs/out \
-e MDX \
-e NEXT_PUBLIC_NAME \
ghcr.io/pmndrs/docs:app-router yarn build
env:
BASE_PATH: ${{ steps.configurepages.outputs.base_path }}
MDX: ${{ inputs.mdx }}
NEXT_PUBLIC_LIBNAME: ${{ inputs.mdx }}
- run: ls -al ${{ inputs.mdx }}

- uses: actions/upload-pages-artifact@v3
with:
path: ${{ inputs.mdx }}/out
18 changes: 3 additions & 15 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Create and publish a multi-arch Docker image
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
name: Create and publish a Docker image
on:
push:
branches: ['main', 'app-router']
Expand All @@ -20,18 +21,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
install: true

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
Expand All @@ -51,13 +40,12 @@ jobs:
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
29 changes: 29 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Create and publish a multi-arch Docker image
on:
push:
branches: ['main', 'app-router']

jobs:
build:
uses: pmndrs/docs/.github/workflows/build.yml@app-router
with:
mdx: ./docs
libname: 'pmndrs'

deploy:
needs: build
runs-on: ubuntu-latest

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- id: deployment
uses: actions/deploy-pages@v4
3 changes: 3 additions & 0 deletions docs/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# hello

this is documentation for @pmndrs/docs
2 changes: 2 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const basePath = process.env.BASE_PATH || ''
const distDir = process.env.DIST_DIR || undefined

/** @type {import('next').NextConfig} */
Expand All @@ -7,6 +8,7 @@ const nextConfig = {
// domains: ['codesandbox.io'],
unoptimized: true,
},
basePath,
output: 'export',
distDir,
// async redirects() {
Expand Down
20 changes: 14 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ $ MDX=docs NEXT_PUBLIC_LIBNAME="React Three Fiber" yarn build

# Docker

```
```sh
$ docker build -t pmndrs-docs .
```

$ docker run --rm --init -it \
-v $(pwd)/docs:/app/docs \
-e DIST_DIR=docs/out \
-e NEXT_PUBLIC_LIBNAME="React Three Fiber" \
pmndrs-docs yarn build
```sh
$ export BASE_PATH=/foo; \
export MDX=./docs; \
export NEXT_PUBLIC_NAME="pmndrs"; \
\
rm -rf "$MDX/out" && docker run --rm --init -it \
-v "$MDX":/app/docs \
-e BASE_PATH \
-e DIST_DIR=docs/out \
-e MDX \
-e NEXT_PUBLIC_NAME \
pmndrs-docs yarn build
```

0 comments on commit 801854b

Please sign in to comment.