From 780b7f1056d002d4bd9c560a1750836ca9037e45 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Fri, 9 Aug 2024 23:21:10 +0200 Subject: [PATCH] reusable + caller --- .github/workflows/build.yml | 40 ++++++++++++++++++++++++++++++++++++ .github/workflows/docker.yml | 20 ++++-------------- .github/workflows/docs.yml | 29 ++++++++++++++++++++++++++ docs/index.mdx | 3 +++ readme.md | 16 ++++++++++----- 5 files changed, 87 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/docs.yml create mode 100644 docs/index.mdx diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..5c0c344d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,40 @@ +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 + - 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 }} + + - run: ls -al ${{ inputs.mdx }} + + - uses: actions/upload-pages-artifact@v3 + with: + path: ${{ inputs.mdx }}/out diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 30f6087f..263a7787 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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 @@ -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: @@ -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 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..d86fc6b3 --- /dev/null +++ b/.github/workflows/docs.yml @@ -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-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 diff --git a/docs/index.mdx b/docs/index.mdx new file mode 100644 index 00000000..0af6389d --- /dev/null +++ b/docs/index.mdx @@ -0,0 +1,3 @@ +# hello + +this is documentation for @pmndrs/docs diff --git a/readme.md b/readme.md index 2307fa65..ebd33f2e 100644 --- a/readme.md +++ b/readme.md @@ -15,12 +15,18 @@ $ MDX=docs NEXT_PUBLIC_LIBNAME="React Three Fiber" yarn build # Docker -``` +```sh $ docker build -t pmndrs-docs . +``` + +```sh +$ export MDX=./docs +$ export NEXT_PUBLIC_NAME="pmndrs" $ 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 ```