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*',