feat(cicd): automate the creation of blog posts #1287
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Security Notes | |
# Only selected Actions are allowed within this repository. Please refer to (https://github.com/nodejs/nodejs.org/settings/actions) | |
# for the full list of available actions. If you want to add a new one, please reach out a maintainer with Admin permissions. | |
# REVIEWERS, please always double-check security practices before merging a PR that contains Workflow changes!! | |
# AUTHORS, please only use actions with explicit SHA references, and avoid using `@master` or `@main` references or `@version` tags. | |
# MERGE QUEUE NOTE: This Workflow does not run on `merge_group` trigger, as this Workflow is not required for Merge Queue's | |
name: Playwright Tests | |
on: | |
pull_request: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
actions: read | |
jobs: | |
get-vercel-preview: | |
name: Get Vercel Preview | |
runs-on: ubuntu-latest | |
outputs: | |
deployment_found: ${{ steps.set_outputs.outputs.deployment_found }} | |
url: ${{ steps.set_outputs.outputs.url }} | |
steps: | |
- name: Capture Vercel Preview | |
id: check_deployment | |
uses: patrickedqvist/wait-for-vercel-preview@06c79330064b0e6ef7a2574603b62d3c98789125 # v1.3.2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
max_timeout: 300 # timeout after 5 minutes | |
check_interval: 10 # check every 10 seconds | |
continue-on-error: true | |
- name: Set Outputs | |
if: always() | |
id: set_outputs | |
run: | | |
if [[ -z "${{ steps.check_deployment.outputs.url }}" ]]; then | |
echo "deployment_found=false" >> $GITHUB_OUTPUT | |
else | |
echo "deployment_found=true" >> $GITHUB_OUTPUT | |
echo "url=${{ steps.check_deployment.outputs.url }}" >> $GITHUB_OUTPUT | |
fi | |
playwright: | |
needs: get-vercel-preview | |
if: needs.get-vercel-preview.outputs.deployment_found == 'true' | |
name: Playwright Tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: nodejs/web-team/actions/setup-environment@2c2897a93eb99b4cdca270729100bc0887c758d9 | |
with: | |
pnpm: true | |
use-version-file: true | |
fetch-depth: 2 | |
- name: Get Playwright version | |
id: playwright-version | |
working-directory: apps/site | |
run: echo "version=$(node_modules/.bin/playwright --version | awk '{print $2}')" >> $GITHUB_OUTPUT | |
- name: Cache Playwright browsers | |
id: playwright-cache | |
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
with: | |
path: ~/.cache/ms-playwright | |
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} | |
- name: Install Playwright Browsers | |
working-directory: apps/site | |
run: node_modules/.bin/playwright install --with-deps | |
- name: Run Playwright tests | |
working-directory: apps/site | |
run: node --run playwright | |
env: | |
PLAYWRIGHT_BASE_URL: ${{ needs.get-vercel-preview.outputs.url }} | |
- name: Upload Playwright test results | |
if: always() | |
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
with: | |
name: playwright-report | |
path: apps/site/playwright-report/ |