From ea7fef699fc2dc60a7f6b2f61e395e6d4ae240a7 Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Mon, 25 Jan 2021 10:28:34 -0500 Subject: [PATCH] Test against deployment url (#10501) * Test against deployment url * Remove infinite redirect configuration * Add DEPLOYMENT_URL for builds against master * website: Update README * tip on seconds * Test with GHA timeout_minutes clause * Add continue on error for poll job * Add empty url check * Move to pull-request path filter * Remove www for packer.io * Apply suggestions from code review * Update path filter Vercel deploys on any change under the website directory. * Use custom action as test Co-authored-by: Adrien Delorme --- .github/workflows/linkchecker.yml | 33 ++++++++++++++++--- .github/workflows/scheduled-link-checker.yml | 3 ++ mlc_config.json | 2 +- website/README.md | 4 ++- .../packer-on-cicd/pipelineing-builds.mdx | 2 +- website/redirects.next.js | 5 --- 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/.github/workflows/linkchecker.yml b/.github/workflows/linkchecker.yml index 27ed60cee..0eaa2d774 100644 --- a/.github/workflows/linkchecker.yml +++ b/.github/workflows/linkchecker.yml @@ -1,14 +1,37 @@ -on: [pull_request] -name: Check Markdown links for modified files +on: + pull_request: + paths: + - 'website/**' + +name: Check markdown links on modified website files jobs: + vercel-deployment-poll: + runs-on: ubuntu-latest + timeout-minutes: 3 #cancel job if no deployment is found within x minutes + outputs: + url: ${{ steps.waitForVercelPreviewDeployment.outputs.url }} + steps: + - name: Wait for Vercel preview deployment to be ready + uses: nywilken/wait-for-vercel-preview@master + id: waitForVercelPreviewDeployment + with: + token: ${{ secrets.GITHUB_TOKEN }} + max_timeout: 600 # in seconds, set really high to leverage job timeout-minutes values + allow_inactive: true # needed to ensure we get a URL for a previously released deployment markdown-link-check: + needs: vercel-deployment-poll + if: ${{ needs.vercel-deployment-poll.outputs.url != '' }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - uses: gaurav-nelson/github-action-markdown-link-check@v1 + - name: Get Deployment URL + run: + echo "DEPLOYMENT_URL=${{ needs.vercel-deployment-poll.outputs.url }}" >> $GITHUB_ENV + - name: Checkout source branch + uses: actions/checkout@master + - name: Check links + uses: gaurav-nelson/github-action-markdown-link-check@v1 with: use-quiet-mode: 'yes' file-extension: 'mdx' check-modified-files-only: 'yes' folder-path: 'website/content' - diff --git a/.github/workflows/scheduled-link-checker.yml b/.github/workflows/scheduled-link-checker.yml index d626f67d2..498936e47 100644 --- a/.github/workflows/scheduled-link-checker.yml +++ b/.github/workflows/scheduled-link-checker.yml @@ -6,6 +6,9 @@ jobs: markdown-link-check: runs-on: ubuntu-latest steps: + - name: Set deployment URL env + run: + echo "DEPLOYMENT_URL=https://packer-git-master.hashicorp.vercel.app" >> $GITHUB_ENV - uses: actions/checkout@master - uses: gaurav-nelson/github-action-markdown-link-check@v1 with: diff --git a/mlc_config.json b/mlc_config.json index 5bd08fbb7..dc52e164a 100644 --- a/mlc_config.json +++ b/mlc_config.json @@ -37,7 +37,7 @@ "replacementPatterns": [ { "pattern": "^/", - "replacement": "https://packer.io/" + "replacement": "{{env.DEPLOYMENT_URL}}/" } ], "timeout": "20s", diff --git a/website/README.md b/website/README.md index 813520dd7..8117006c4 100644 --- a/website/README.md +++ b/website/README.md @@ -379,7 +379,9 @@ You may customize the parameters in any way you'd like. To remove a prerelease f ## Link Validation -The Packer GitHub repository is configured to run a [Markdown Link Check](https://github.com/gaurav-nelson/github-action-markdown-link-check#github-action---markdown-link-check-%EF%B8%8F) on a nightly basis to check for potential broken links within the Packer documentation. There is also a GitHub action that will check any modified `.mdx` files on new pull-requests. +The Packer GitHub repository is configured to run a [Markdown Link Check](https://github.com/gaurav-nelson/github-action-markdown-link-check#github-action---markdown-link-check-%EF%B8%8F) on a nightly basis to check for potential broken links within the Packer documentation. All checks on master will be executed using the BASE_URL set to https://packer.io/. + +There is also a GitHub action that will check any modified `website/content/**/*.mdx` files on new pull-requests. The link checker action for pull-requests will only run when there is a new Vercel deployment; checks will be executed against the Vercel deployment URL. If no deployment is made the check will run but will timeout after 3 minutes since it needs a valid Vercel deployment URL. The master configuration file for the markdown-link-checker is called `mlc_config.json` and is located under the project's root directory. The configuration helps with relative links in the documentation that will be valid once deployed, and configures a few ignored URLs which are valid but may not return a valid 200 HTTP response code due to permissions or DDoS protection settings on the domain. diff --git a/website/content/guides/packer-on-cicd/pipelineing-builds.mdx b/website/content/guides/packer-on-cicd/pipelineing-builds.mdx index 77651cd02..571962b43 100644 --- a/website/content/guides/packer-on-cicd/pipelineing-builds.mdx +++ b/website/content/guides/packer-on-cicd/pipelineing-builds.mdx @@ -118,7 +118,7 @@ build { In order to build using this template, create a directory named "http" in your current working directory. Copy the minimal example from our -[preseed guide](https://www.packer.io/guides/automatic-operating-system-installs/preseed_ubuntu#examples) +[preseed guide](https://packer.io/guides/automatic-operating-system-installs/preseed_ubuntu#examples) into a file in your http directory and name it "ubuntu_preseed.cfg". Copy the above json template into your current working directory and save it as "example_virtualbox_iso.json" diff --git a/website/redirects.next.js b/website/redirects.next.js index 2200afa65..6c6fd8381 100644 --- a/website/redirects.next.js +++ b/website/redirects.next.js @@ -146,11 +146,6 @@ module.exports = [ destination: '/docs/templates/hcl_templates/:path*', permanent: true, }, - { - source: '/docs/templates/hcl_templates/:path*', - destination: '/docs/templates/hcl_templates/:path*', - permanent: true, - }, { source: '/docs/templates/hcl_templates/:path*/overview', destination: '/docs/templates/hcl_templates/:path*',