From 880f871912c23e7032f63c782d126c77ac518313 Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Mon, 24 Feb 2025 14:01:16 -0600 Subject: [PATCH 1/5] Update GH pages workflows according to the GH sample --- .github/workflows/preview-on-pages.yml | 72 ++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/preview-on-pages.yml diff --git a/.github/workflows/preview-on-pages.yml b/.github/workflows/preview-on-pages.yml new file mode 100644 index 0000000..7950240 --- /dev/null +++ b/.github/workflows/preview-on-pages.yml @@ -0,0 +1,72 @@ +name: Deploy Gatsby site to Pages + +on: workflow_dispatch + +# 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 + +# Default to bash +defaults: + run: + shell: bash + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: yarn + - name: Setup Pages + id: pages + uses: actions/configure-pages@v5 + with: + # Automatically inject pathPrefix in your Gatsby configuration file. + # + # You may remove this line if you want to manage the configuration yourself. + static_site_generator: gatsby + - name: Restore cache + uses: actions/cache@v4 + with: + path: | + public + .cache + key: ${{ runner.os }}-gatsby-build-${{ hashFiles('public') }} + restore-keys: | + ${{ runner.os }}-gatsby-build- + - name: Install dependencies + run: yarn install + - name: Build with Gatsby + env: + PREFIX_PATHS: 'true' + run: yarn run build + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./public + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 From 3b3dd4ed04b9fa321763f4372df76a28a89bda75 Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Mon, 24 Feb 2025 14:04:42 -0600 Subject: [PATCH 2/5] Use the existing workflow --- .github/workflows/github-pages.yml | 96 +++++++++++++++++------------- 1 file changed, 55 insertions(+), 41 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index b0ba445..7950240 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -1,58 +1,72 @@ ---- -name: Github Pages +name: Deploy Gatsby site to Pages + on: workflow_dispatch -permissions: {} + +# 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 + +# Default to bash +defaults: + run: + shell: bash + jobs: + # Build job build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Use Setup Node and Install Dependencies Action - uses: commerce-docs/devsite-install-action@main + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' - cache-dependency-path: 'yarn.lock' - - - name: Build site - id: build - run: yarn build + cache: yarn + - name: Setup Pages + id: pages + uses: actions/configure-pages@v5 + with: + # Automatically inject pathPrefix in your Gatsby configuration file. + # + # You may remove this line if you want to manage the configuration yourself. + static_site_generator: gatsby + - name: Restore cache + uses: actions/cache@v4 + with: + path: | + public + .cache + key: ${{ runner.os }}-gatsby-build-${{ hashFiles('public') }} + restore-keys: | + ${{ runner.os }}-gatsby-build- + - name: Install dependencies + run: yarn install + - name: Build with Gatsby env: - NODE_OPTIONS: "--max-old-space-size=8192" - PREFIX_PATHS: true # works like --prefix-paths flag for 'gatsby build' - PATH_PREFIX: ${{ github.event.repository.name }} - ADOBE_LAUNCH_SRC: ${{ secrets.AIO_ADOBE_LAUNCH_SRC }} - ADOBE_LAUNCH_SRC_INCLUDE_IN_DEVELOPMENT: ${{ secrets.ADOBE_LAUNCH_SRC_INCLUDE_IN_DEVELOPMENT }} - REPO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPO_OWNER: ${{ github.event.repository.owner.login }} - REPO_NAME: ${{ github.event.repository.name }} - REPO_BRANCH: ${{ github.ref_name }} - GOOGLE_OAUTH_CLIENT_ID: ${{ secrets.GOOGLE_OAUTH_CLIENT_ID }} - GOOGLE_OAUTH_CLIENT_SECRET: ${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }} - GOOGLE_DOCS_TOKEN: ${{ secrets.GOOGLE_DOCS_TOKEN }} - GOOGLE_DOCS_FOLDER_ID: ${{ secrets.GOOGLE_DOCS_FOLDER_ID }} - - name: Upload static files as artifact - id: deployment - uses: actions/upload-pages-artifact@v3 # or specific "vX.X.X" version tag for this action + PREFIX_PATHS: 'true' + run: yarn run build + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 with: - path: public - # Deploy job - deploy: - # Add a dependency to the build job - needs: build - - # 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 + path: ./public - # Deploy to the github-pages environment + # Deployment job + deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - - # Specify runner + deployment step runs-on: ubuntu-latest + needs: build steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action + uses: actions/deploy-pages@v4 From 6841fd1e473a139c4ba3852f761ed4ea7e77f096 Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Mon, 24 Feb 2025 14:50:54 -0600 Subject: [PATCH 3/5] Refactor via reusable workflow --- .github/workflows/deploy-to-pages.yml | 55 +++++++++++++++++++++++++++ .github/workflows/github-pages.yml | 54 ++------------------------ 2 files changed, 59 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/deploy-to-pages.yml diff --git a/.github/workflows/deploy-to-pages.yml b/.github/workflows/deploy-to-pages.yml new file mode 100644 index 0000000..d56192b --- /dev/null +++ b/.github/workflows/deploy-to-pages.yml @@ -0,0 +1,55 @@ +name: Deploy Gatsby site to Pages + +on: workflow_call + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: yarn + - name: Setup Pages + id: pages + uses: actions/configure-pages@v5 + with: + # Automatically inject pathPrefix in your Gatsby configuration file. + # + # You may remove this line if you want to manage the configuration yourself. + static_site_generator: gatsby + - name: Restore cache + uses: actions/cache@v4 + with: + path: | + public + .cache + key: ${{ runner.os }}-gatsby-build-${{ hashFiles('public') }} + restore-keys: | + ${{ runner.os }}-gatsby-build- + - name: Install dependencies + run: yarn install + - name: Build with Gatsby + env: + PREFIX_PATHS: 'true' + run: yarn run build + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./public + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 7950240..4d8ba74 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -1,3 +1,4 @@ +# The workflow is based on a starter workflow https://github.com/actions/starter-workflows/blob/main/pages/gatsby.yml name: Deploy Gatsby site to Pages on: workflow_dispatch @@ -20,53 +21,6 @@ defaults: shell: bash jobs: - # Build job - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: yarn - - name: Setup Pages - id: pages - uses: actions/configure-pages@v5 - with: - # Automatically inject pathPrefix in your Gatsby configuration file. - # - # You may remove this line if you want to manage the configuration yourself. - static_site_generator: gatsby - - name: Restore cache - uses: actions/cache@v4 - with: - path: | - public - .cache - key: ${{ runner.os }}-gatsby-build-${{ hashFiles('public') }} - restore-keys: | - ${{ runner.os }}-gatsby-build- - - name: Install dependencies - run: yarn install - - name: Build with Gatsby - env: - PREFIX_PATHS: 'true' - run: yarn run build - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: ./public - - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + call-workflow-deploy-to-pages: + uses: commerce-docs/commerce-testing/.github/workflows/deploy-to-pages.yml@ds_pages + secrets: inherit From 6783ba0b0e1bf85ddce32fd1faaa2e3b64c1a8a3 Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Tue, 25 Feb 2025 10:30:32 -0600 Subject: [PATCH 4/5] Use AdobeDocs org for remote call --- .github/workflows/github-pages.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 4d8ba74..2ea6fe5 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -1,26 +1,20 @@ -# The workflow is based on a starter workflow https://github.com/actions/starter-workflows/blob/main/pages/gatsby.yml name: Deploy Gatsby site to Pages on: workflow_dispatch -# 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 -# Default to bash defaults: run: shell: bash jobs: call-workflow-deploy-to-pages: - uses: commerce-docs/commerce-testing/.github/workflows/deploy-to-pages.yml@ds_pages - secrets: inherit + uses: AdobeDocs/commerce-php/.github/workflows/deploy-to-pages_job.yml@main From 20662d903ccc8ab62db70cc682968e8341d043d3 Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Tue, 25 Feb 2025 10:31:47 -0600 Subject: [PATCH 5/5] Delete redundant file --- .github/workflows/preview-on-pages.yml | 72 -------------------------- 1 file changed, 72 deletions(-) delete mode 100644 .github/workflows/preview-on-pages.yml diff --git a/.github/workflows/preview-on-pages.yml b/.github/workflows/preview-on-pages.yml deleted file mode 100644 index 7950240..0000000 --- a/.github/workflows/preview-on-pages.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Deploy Gatsby site to Pages - -on: workflow_dispatch - -# 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 - -# Default to bash -defaults: - run: - shell: bash - -jobs: - # Build job - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: yarn - - name: Setup Pages - id: pages - uses: actions/configure-pages@v5 - with: - # Automatically inject pathPrefix in your Gatsby configuration file. - # - # You may remove this line if you want to manage the configuration yourself. - static_site_generator: gatsby - - name: Restore cache - uses: actions/cache@v4 - with: - path: | - public - .cache - key: ${{ runner.os }}-gatsby-build-${{ hashFiles('public') }} - restore-keys: | - ${{ runner.os }}-gatsby-build- - - name: Install dependencies - run: yarn install - - name: Build with Gatsby - env: - PREFIX_PATHS: 'true' - run: yarn run build - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: ./public - - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4