From 74e4cbee5412a4b5211dcefa0db5885ed51ad454 Mon Sep 17 00:00:00 2001 From: Martin Skopp Date: Wed, 17 Apr 2024 17:48:58 +0200 Subject: [PATCH] Try another way to support copying of resources to docs/ --- .../pages-generate-from-docs-dir.yml | 33 +++++++- .../pages-generate-with-file-copy.yml | 80 ------------------- .github/workflows/pages.yml | 3 + docs/index.md | 4 +- 4 files changed, 37 insertions(+), 83 deletions(-) delete mode 100644 .github/workflows/pages-generate-with-file-copy.yml diff --git a/.github/workflows/pages-generate-from-docs-dir.yml b/.github/workflows/pages-generate-from-docs-dir.yml index 23298dd..86bf940 100644 --- a/.github/workflows/pages-generate-from-docs-dir.yml +++ b/.github/workflows/pages-generate-from-docs-dir.yml @@ -2,6 +2,23 @@ name: Deploy static content from /docs to GitHub Pages on: # yamllint disable-line rule:truthy workflow_call: + inputs: + from1: + required: false + type: string + description: "Optional subdirectory to copy into docs, it will do cp -r inputs.from1/* build/docs/inputs.to1" + to1: + required: false + type: string + description: "Optional but required if from1 is provided: Target directly under 'docs/' to copy into" + from2: + required: false + type: string + description: "Optional 2nd subdirectory into docs, it will do cp -r inputs.from2/* build/docs/inputs.to2" + to2: + required: false + type: string + description: "Optional but required if from2 is provided: Target directly under 'docs/' to copy into" # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages #permissions: @@ -55,7 +72,7 @@ jobs: # witin the folder named _github-pages-build # So ${{ github.workspace }}/_github-pages-build/pages-layout # contains the _layouts and assets folder. - # + # cd ${{ github.workspace }} mkdir -p build/docs cp -r _github-pages-build/pages-layout/* build/docs @@ -67,9 +84,21 @@ jobs: # _layouts, assets (also from docs, should be from a template dir) ### schemas (content = src/main/resources/schemas/*) + - name: Copy recursively FROM1 to TO1, e.g. from1=src/main/resources/schemas to1=schemas + if: ${{ inputs.from1 }} + run: | + mkdir -p build/docs/${{ inputs.to1 }} + cp -r ${{ inputs.from1 }}/* build/docs/${{ inputs.to1 }}/ + + - name: Copy recursively FROM2 to TO2, e.g. from2=src/main/resources/schemas to2=schemas + if: ${{ inputs.from2 }} + run: | + mkdir -p build/docs/${{ inputs.to2 }} + cp -r ${{ inputs.from2 }}/* build/docs/${{ inputs.to2 }}/ + - name: Setup Pages uses: actions/configure-pages@v5 - + - name: Build HTML from pages .md and .html uses: actions/jekyll-build-pages@v1 with: diff --git a/.github/workflows/pages-generate-with-file-copy.yml b/.github/workflows/pages-generate-with-file-copy.yml deleted file mode 100644 index dff4686..0000000 --- a/.github/workflows/pages-generate-with-file-copy.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Deploy static content from /docs to GitHub Pages, without checkout of the repository - -on: # yamllint disable-line rule:truthy - workflow_call: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -#permissions: -# contents: read -# pages: write -# id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. -concurrency: - group: "pages" - cancel-in-progress: false - -jobs: - # Single deploy job since we're just deploying - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - steps: - - name: Generate Pages content - run: | - cd ${{ github.workspace }} - mkdir -p build - cp -r docs build/ - # at his point, "build/docs" contains folders - # index.md, examples (from docs) - # _layouts, assets (also from docs, should be from a template dir) - - - name: Checkout blueprints - uses: actions/checkout@v4 - with: - repository: riege/github-pages-build - sparse-checkout: pages-layout - path: _github-pages-build - - - name: Apply blueprints - run: | - # Example when this is invoked from a repo playground-mskopp2: - # github.workspace = /home/runner/work/playground-mskopp2/playground-mskopp2 - # it contains the checked out repository playground-mskopp2 - # plus the contant of riege/github-pages-build - # limited to root folder files plus sub directlry pages-layout - # witin the folder named _github-pages-build - # So ${{ github.workspace }}/_github-pages-build/pages-layout - # contains the _layouts and assets folder. - # - cd ${{ github.workspace }} - mkdir -p build/docs - cp -r _github-pages-build/pages-layout/* build/docs - cp -r docs/* build/docs - ### mkdir -p build/docs/schemas - ### cp -r src/main/resources/schemas/* build/docs/schemas/ - # at his point, "build/docs" contains folders - # index.md, examples (from docs) - # _layouts, assets (also from docs, should be from a template dir) - ### schemas (content = src/main/resources/schemas/*) - - - name: Setup Pages - uses: actions/configure-pages@v5 - - - name: Build HTML from pages .md and .html - uses: actions/jekyll-build-pages@v1 - with: - source: build/docs - destination: build/pages - - - name: Upload Pages artifact - uses: actions/upload-pages-artifact@v3 - with: - path: build/pages - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 81cac87..28cf871 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -29,3 +29,6 @@ jobs: # Single pages job since we're just building and deploying GitHub pages pages: uses: "riege/github-pages-build/.github/workflows/pages-generate-from-docs-dir.yml@main" + with: + from1: img + to1: demo-img diff --git a/docs/index.md b/docs/index.md index 59f9b36..2ab48c7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,4 +4,6 @@ This is the index.md file to demonstrate usage of a general workflows and layouts to build GitHub pages from a Riege Software GitHub repository. -For more information, see [github.com/riege/github-pages-build](https://github.com/riege/github-pages-build). +For more information, see README in [github.com/riege/github-pages-build](https://github.com/riege/github-pages-build). + +Note: The following link to [demo-img/pages-settings.png](demo-img/pages-settings.png) is a test for the from/to copy option.