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 9c0ec92
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 21 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Reusable pmndrs/docs workflow

on:
workflow_call:
inputs:
mdx:
required: true
type: string
libname:
required: true
type: string
outputs:
firstword:
description: 'The first output string'
value: ${{ jobs.build-job.outputs.output1 }}

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

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

outputs:
output1: ${{ steps.artifact-upload-step.outputs.artifact-id }}
steps:
- uses: actions/checkout@v4
- run: |
docker run --rm --init \
-v "$MDX":/app/docs \
-e DIST_DIR=docs/out \
-e MDX \
-e NEXT_PUBLIC_NAME \
ghcr.io/pmndrs/docs:app-router yarn build
env:
MDX: ${{ inputs.mdx }}
NEXT_PUBLIC_LIBNAME: ${{ inputs.mdx }}
- id: artifact-upload-step
uses: actions/upload-artifact@v4
with:
path: ${{ inputs.mdx }}/out
20 changes: 4 additions & 16 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
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']
branches: ['main']

env:
REGISTRY: ghcr.io
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
31 changes: 31 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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-docs'

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
with:
artifact_name: ${{ needs.build.outputs.firstword }}
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
16 changes: 11 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ $ MDX=docs NEXT_PUBLIC_LIBNAME="React Three Fiber" yarn build

# Docker

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

```sh
$ export MDX=~/code/pmndrs/react-three-fiber/docs
$ export NEXT_PUBLIC_NAME="React Three Fiber"

$ 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
-v "$MDX":/app/docs \
-e DIST_DIR=docs/out \
-e MDX \
-e NEXT_PUBLIC_NAME \
ghcr.io/pmndrs/docs:app-router yarn build
```

0 comments on commit 9c0ec92

Please sign in to comment.