Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skip deploy] port actions from dev docs repo #124

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/cron-link-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# MegaLinter GitHub Action configuration file for our daily link check.
# This action runs a link check on our entire doc set every day at 12:00 AM so we're warned when a link breaks.
# This is a separate workflow file from main Megalinter checks because we needed to use different settings for this run.

name: Daily Link Check
on:
schedule:
# Run everyday at 12:00 AM
- cron: "0 0 * * *"

jobs:
build:
name: MegaLinter
runs-on: ubuntu-latest
steps:
# Git Checkout
- name: Checkout Code
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0


- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2' # Adjust as needed
extensions: bcmath, ctype, exif, json, mbstring, openssl, pdo, tokenizer, xml, gd
tools: composer, php-cs-fixer

- name: Install Dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install NPM Dependencies
run: npm install
# External Link Check
- name: Internal Link Check
run: ./linkchecker external
41 changes: 41 additions & 0 deletions .github/workflows/internal-link-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Internal Link Check

on:
# Trigger at every push. Action will also be visible from Pull Requests to master
pull_request:
branches:
- main

jobs:
build:
name: Internal Link Check
runs-on: ubuntu-latest
steps:
# Git Checkout
- name: Checkout Code
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2' # Adjust as needed
extensions: bcmath, ctype, exif, json, mbstring, openssl, pdo, tokenizer, xml, gd
tools: composer, php-cs-fixer

- name: Install Dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install NPM Dependencies
run: npm install

# Internal Link Check
- name: Internal Link Check
run: ./linkchecker
50 changes: 50 additions & 0 deletions .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
# MegaLinter GitHub Action configuration file
# This action runs on every push to a PR against main. It checks the entire docset for markdown violations and broken links.
# This is separate from the Megalinter cron job that runs daily (see cron-link-check.yml) to check for broken links.
# More info at https://megalinter.github.io
name: MegaLinter

on:
# Trigger mega-linter at every push. Action will also be visible from Pull Requests to master
pull_request:
branches: [master, main]

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
build:
name: MegaLinter
runs-on: ubuntu-latest
steps:
# Git Checkout
- name: Checkout Code
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0

# MegaLinter
- name: MegaLinter
id: ml
# You can override MegaLinter flavor used to have faster performances
# More info at https://megalinter.github.io/flavors/
uses: oxsecurity/megalinter/flavors/documentation@v6
env:
# All available variables are described in documentation
# https://megalinter.github.io/configuration/
VALIDATE_ALL_CODEBASE: false # checks only diff against main.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY

# Upload MegaLinter artifacts
- name: Archive production artifacts
if: ${{ success() }} || ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: MegaLinter reports
path: |
report
mega-linter.log
34 changes: 34 additions & 0 deletions .github/workflows/spell-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Spell Checker

on:
pull_request:
branches: [main]

jobs:
build:
name: Spell Checker
runs-on: ubuntu-latest
steps:
# Git Checkout
- name: Checkout Code
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Spell Check
uses: streetsidesoftware/cspell-action@v3
with:
github_token: '${{ secrets.PAT || secrets.GITHUB_TOKEN }}'
files: '**/*.md'
incremental_files_only: true
config: '.'
# Setup Node
# - name: Setup Node 18
# uses: actions/setup-node@v3
# with:
# node-version: 18
# - name: Install spell checker
# run: npm i -g cspell@^6.31.2
# # cspell
# - name: Run spell checker
# run: cspell lint -c cspell.json --show-context --no-progress --relative "**/*.md"
17 changes: 17 additions & 0 deletions .github/workflows/vale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: reviewdog
on: [pull_request]

jobs:
vale:
name: runner / vale
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: errata-ai/vale-action@reviewdog
with:
files: collections/
filter_mode: added
env:
# Required, set by GitHub actions automatically:
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
5 changes: 3 additions & 2 deletions linkchecker
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/bash

# Rebuild the site
npm run build
php please ssg:generate --workers=4

# Run the link checker on the local site
if [ "$1" = "external" ]; then
# Also check external links. Requires additional filtering
exec 5>&1
echo "Running full link check, including external links. This may take some time..."
out=$( npx -y broken-link-checker-local@latest ./site -rog \
out=$( npx -y broken-link-checker-local@latest ./storage/app/static/docs -b /docs -rog \
--exclude 'https://help.amplitude.com' \
--exclude 'https://api.amplitude.com' \
--exclude 'https://api2.ampliude.com' \
Expand All @@ -24,7 +25,7 @@ else
# Check only internal links
exec 5>&1
echo "Running internal link check..."
out=$( npx -y broken-link-checker-local@latest ./storage/app/static -roe \
out=$( npx -y broken-link-checker-local@latest ./storage/app/static/docs -b /docs -roe \
| grep --line-buffered 'BROKEN\|Getting links from' \
| tee >(cat - >&5) )
fi
Expand Down
Loading