From 21932f871a31e57e7361f0f5e23a826e6f5327c8 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 | 51 ++++++++++++++++++++++++++++++++++++ .github/workflows/docker.yml | 20 +++----------- .github/workflows/docs.yml | 32 ++++++++++++++++++++++ docs/index.mdx | 3 +++ readme.md | 16 +++++++---- 5 files changed, 101 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..4471f2da --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,51 @@ +name: Reusable pmndrs/docs workflow + +on: + workflow_call: + inputs: + mdx: + required: true + type: string + libname: + required: true + type: string + artifact_name: + default: 'out-artifact' + 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 }} + + - run: ls -al ${{ inputs.mdx }} + + - id: artifact-upload-step + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.artifact_name }} + 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..a2e5405a --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,32 @@ +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' + artifact_name: github-pages + + 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: github-pages 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..cae2239f 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="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 ```