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 <azr@users.noreply.github.com>
This commit is contained in:
Wilken Rivera 2021-01-25 10:28:34 -05:00 committed by GitHub
parent e588029d6a
commit ea7fef699f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 13 deletions

View File

@ -1,14 +1,37 @@
on: [pull_request] on:
name: Check Markdown links for modified files pull_request:
paths:
- 'website/**'
name: Check markdown links on modified website files
jobs: 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: markdown-link-check:
needs: vercel-deployment-poll
if: ${{ needs.vercel-deployment-poll.outputs.url != '' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@master - name: Get Deployment URL
- uses: gaurav-nelson/github-action-markdown-link-check@v1 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: with:
use-quiet-mode: 'yes' use-quiet-mode: 'yes'
file-extension: 'mdx' file-extension: 'mdx'
check-modified-files-only: 'yes' check-modified-files-only: 'yes'
folder-path: 'website/content' folder-path: 'website/content'

View File

@ -6,6 +6,9 @@ jobs:
markdown-link-check: markdown-link-check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set deployment URL env
run:
echo "DEPLOYMENT_URL=https://packer-git-master.hashicorp.vercel.app" >> $GITHUB_ENV
- uses: actions/checkout@master - uses: actions/checkout@master
- uses: gaurav-nelson/github-action-markdown-link-check@v1 - uses: gaurav-nelson/github-action-markdown-link-check@v1
with: with:

View File

@ -37,7 +37,7 @@
"replacementPatterns": [ "replacementPatterns": [
{ {
"pattern": "^/", "pattern": "^/",
"replacement": "https://packer.io/" "replacement": "{{env.DEPLOYMENT_URL}}/"
} }
], ],
"timeout": "20s", "timeout": "20s",

View File

@ -379,7 +379,9 @@ You may customize the parameters in any way you'd like. To remove a prerelease f
## Link Validation ## 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 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. 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.

View File

@ -118,7 +118,7 @@ build {
In order to build using this template, create a directory named "http" in your In order to build using this template, create a directory named "http" in your
current working directory. Copy the minimal example from our 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 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 above json template into your current working directory and save it as
"example_virtualbox_iso.json" "example_virtualbox_iso.json"

View File

@ -146,11 +146,6 @@ module.exports = [
destination: '/docs/templates/hcl_templates/:path*', destination: '/docs/templates/hcl_templates/:path*',
permanent: true, permanent: true,
}, },
{
source: '/docs/templates/hcl_templates/:path*',
destination: '/docs/templates/hcl_templates/:path*',
permanent: true,
},
{ {
source: '/docs/templates/hcl_templates/:path*/overview', source: '/docs/templates/hcl_templates/:path*/overview',
destination: '/docs/templates/hcl_templates/:path*', destination: '/docs/templates/hcl_templates/:path*',