From 670481e3d01955800ff44b7aefde6b699c857f0c Mon Sep 17 00:00:00 2001 From: Marco Falkenberg Date: Tue, 30 Jan 2024 09:37:33 +0100 Subject: [PATCH] ci: publish review docs --- .github/workflows/coverage-badges.yml | 5 +- .github/workflows/coverage.yml | 3 +- .github/workflows/publish-docs.yml | 36 ++++++----- .github/workflows/publish-review-docs.yml | 73 +++++++++++++++++++++++ .github/workflows/publish.yml | 39 ++++++++---- .github/workflows/test.yml | 2 +- nx.json | 2 +- packages/docs/next.config.js | 2 +- 8 files changed, 131 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/publish-review-docs.yml diff --git a/.github/workflows/coverage-badges.yml b/.github/workflows/coverage-badges.yml index dc90165ae..1fb5f7839 100644 --- a/.github/workflows/coverage-badges.yml +++ b/.github/workflows/coverage-badges.yml @@ -1,4 +1,5 @@ -name: "coverage-badges" +name: Create Jest coverage badges + on: push: branches: @@ -32,4 +33,4 @@ jobs: coverage-summary-path: ./packages/components/coverage/coverage-summary.json - name: Push badges branch - run: git push origin badges \ No newline at end of file + run: git push origin badges diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index af268bdc9..7be30eaff 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,4 +1,5 @@ -name: "coverage" +name: "Build Jest coverage report" + on: pull_request: branches: diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 28960e8df..6f135c5f9 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -1,4 +1,5 @@ -name: Publish docs +name: Publish docs to GitHub Pages + on: push: branches: @@ -9,36 +10,43 @@ permissions: pages: write id-token: write -concurrency: - group: "pages" - cancel-in-progress: false - jobs: build: 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 🔨 + env: + NEXT_BASE_PATH: "/flow" + 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 diff --git a/.github/workflows/publish-review-docs.yml b/.github/workflows/publish-review-docs.yml new file mode 100644 index 000000000..f48417413 --- /dev/null +++ b/.github/workflows/publish-review-docs.yml @@ -0,0 +1,73 @@ +name: Publish review docs + +on: + push: + branches-ignore: + - main + +permissions: + contents: read + +env: + TARGET_PATH: "/docs/${{ github.ref_name }}" + NEXT_BASE_PATH: "/flow-previews/docs/${{ github.ref_name }}" + +jobs: + deploy: + runs-on: ubuntu-latest + + environment: + name: github-pages-preview + url: https://mittwald.github.io${{ env.NEXT_BASE_PATH }} + + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + PUBLISH_PAT: ${{ secrets.PUBLISH_PAT }} + GH_TOKEN: ${{ secrets.PUBLISH_PAT }} + + steps: + - name: Checkout ⬇️ + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.PUBLISH_PAT }} + + - name: Setup Node 🎛️ + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "yarn" + registry-url: "https://registry.npmjs.org" + + - name: Git Identity 🪪 + run: | + git config user.name "${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.github.com" + + - 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 files to GitHub Pages 🚀 + uses: cpina/github-action-push-to-another-repository@main + env: + API_TOKEN_GITHUB: ${{ secrets.PUBLISH_PAT }} + with: + source-directory: packages/docs/out + destination-github-username: mittwald + destination-repository-name: flow-previews + target-branch: main + target-directory: "${{ env.TARGET_PATH }}" + + - name: Output the URL + run: echo "${{ job.environment.url }}" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 672f72865..264c2a834 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,38 +1,55 @@ -name: Publish +name: Publish packages to NPM + on: pull_request: - types: [closed] + types: + - closed branches: - main jobs: - main: + publish: runs-on: ubuntu-latest + env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} PUBLISH_PAT: ${{ secrets.PUBLISH_PAT }} GH_TOKEN: ${{ secrets.PUBLISH_PAT }} + steps: - - uses: actions/checkout@v4 + - name: Checkout ⬇️ + uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.PUBLISH_PAT }} - - 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" - - name: Git Identity + + - name: Git Identity 🪪 run: | git config user.name "${{ github.actor }}" git config user.email "${{ github.actor }}@users.noreply.github.com" - - 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 - - name: "Version and publish" + + - name: Build 🔨 + run: yarn nx affected -t build --parallel=3 + + - name: Version and publish 🚀 run: | yarn lerna publish \ --conventional-commits --conventional-prerelease=* \ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bec304e0e..d53fbcea3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Test +name: Run tests on: push: branches: diff --git a/nx.json b/nx.json index 278a0e8d2..a264d6688 100644 --- a/nx.json +++ b/nx.json @@ -1,7 +1,7 @@ { "$schema": "./node_modules/nx/schemas/nx-schema.json", "affected": { - "defaultBase": "master" + "defaultBase": "main" }, "namedInputs": { "src": ["{projectRoot}/{src,dev}/**/!(*.test).*"], diff --git a/packages/docs/next.config.js b/packages/docs/next.config.js index b5aed7fb2..477be5235 100644 --- a/packages/docs/next.config.js +++ b/packages/docs/next.config.js @@ -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({