Skip to content
Draft
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
214 changes: 21 additions & 193 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,101 +33,6 @@ commands:
- ~/.cache/

jobs:
snyk-scan:
docker:
- image: cimg/python:3.10
steps:
- attach_workspace:
at: ~/project
- checkout
- platform-helpers-general/step-load-dependencies
- platform-helpers-general/step-run-snyk-monitor:
scan-all-projects: true
skip-unresolved: false
run-on-non-main: true

inclusive-linting:
docker:
- image: cimg/base:current
resource_class: small
steps:
- checkout
- run: bash ./scripts/inclusive-lint.sh

node_build_checks:
docker:
- image: cimg/node:14.21.3-browsers
resource_class: large
environment:
NODE_OPTIONS: '--max_old_space_size=3584'
steps:
- checkout
- install-deps
- run:
name: Lint
command: yarn lint-all
- run:
name: Build
command: yarn build
- run:
name: Run checks
command: ./scripts/yarn-checks-ci.sh
- store_test_results:
path: test_results
- store_artifacts:
path: /tests/cypress/screenshots
- persist_to_workspace:
root: ~/project
paths:
- .
- .git

nightly_link_checker:
docker:
- image: cimg/node:14.21.3-browsers
resource_class: large
environment:
NODE_OPTIONS: '--max_old_space_size=3584'
steps:
- checkout
- install-deps
- run:
name: Run script and capture logs
command: yarn build
- run:
name: Run link checker
command: yarn broken-link-checker:external 2>&1 | tee output.txt || true
- run:
name: Extract URLs from log
command: |
grep -o 'Link: https\?://[^[:space:]]*' output.txt | sed 's/Link: //' > urls.txt
cat urls.txt
when: always
- run:
name: Remove False Positives
command: |
comm -23 <(sort urls.txt | uniq) <(sort falsepos.txt | uniq) > broken_external_urls.txt
- run:
name: Print urls to log
command: |
cat broken_external_urls.txt
- run:
name: Send failure email if broken URLs found
when: on_success
command: |
broken_urls=$(comm -23 <(sort urls.txt | uniq) <(sort falsepos.txt | uniq))
broken_urls=$(echo "$broken_urls" | sed 's/ /\n/g')
formatted_broken_urls=$(echo "$broken_urls" | awk '{printf "<a href=\"%s\">%s</a><br/>\n", $0, $0}')

if [ -n "$broken_urls" ]; then
curl --location --request POST 'https://www.cinotify.cc/api/notify' \
-d "to=${NOTIFY_EMAIL}&subject=BROKEN URLS DETECTED: Dev Docs Nightly Job&type=text/html&body=<p style='font-family: Arial, sans-serif; font-size: 16px; color: #333; line-height: 1.6; text-align: center; background-color: #ffcccc; padding: 10px;'>
<span style='font-weight: bold;'>Nightly link checker job complete. See the list of broken URLs below.</span><br><br>
<a href='https://app.circleci.com/pipelines/github/okta/okta-developer-docs/<< pipeline.number >>' style='display: inline-block; padding: 5px 10px; background-color: #4caf50; color: white; text-decoration: none;'>Click here</a>
to see job details.<br>
</p><h2 style='font-family: Arial, sans-serif; font-size: 16px; color: #333; line-height: 1.6; text-align: center;'>List of broken URLs:</h2>$formatted_broken_urls"
fi

netlify_manual:
docker:
- image: cimg/node:14.21.3-browsers
Expand All @@ -136,6 +41,8 @@ jobs:
- run:
name: Has secrets?
command: |
NETLIFY_AUTH_TOKEN="$NETLIFY_AUTH_TOKEN_2"
NETLIFY_SITE_ID="$NETLIFY_SITE_ID_2"
if [ -z "$NETLIFY_AUTH_TOKEN" ] || [ -z "$NETLIFY_SITE_ID" ]; then
echo "Missing required secrets."
exit 1
Expand All @@ -145,113 +52,34 @@ jobs:
- run:
name: Build preview
command: |
# mkdir -p packages/@okta/vuepress-site/dist
# pushd packages/@okta/vuepress-site/dist
# echo hi>readme.md
# popd
yarn build
- run:
name: Install Netlify CLI
command: |
npm install netlify-cli@17.23.5 -g
- run:
name: Deploy preview to Netlify
command: |
netlify deploy --alias=preview-${CIRCLE_PULL_REQUEST##*/} --filter @okta/vuepress-site
- run:
name: Log preview link
command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
PR_NUMBER="${CIRCLE_PULL_REQUEST##*/}"
echo "Preview link:"
echo "https://preview-${PR_NUMBER}--reverent-murdock-829d24.netlify.app"
else
echo "No pull request detected. Preview link not available."
fi
- persist_to_workspace:
root: packages/@okta/vuepress-site/dist
paths:
- .

netlify_manual_with_redirects:
netlify_publish:
docker:
- image: cimg/node:14.21.3-browsers
- image: cimg/node:18.20.0-browsers
resource_class: xlarge
steps:
- attach_workspace:
at: packages/@okta/vuepress-site/dist
- run:
name: Has secrets?
command: |
if [ -z "$NETLIFY_AUTH_TOKEN" ] || [ -z "$NETLIFY_SITE_ID" ]; then
echo "Missing required secrets."
exit 1
fi
- checkout
- install-deps
- run:
name: Build preview
command: |
yarn build-with-redirect
- run:
name: Install Netlify CLI
command: |
npm install netlify-cli@17.23.5 -g
- run:
name: Deploy preview to Netlify
command: |
netlify deploy --alias=preview-${CIRCLE_PULL_REQUEST##*/} --filter @okta/vuepress-site
- run:
name: Log preview link
command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
PR_NUMBER="${CIRCLE_PULL_REQUEST##*/}"
echo "Preview link:"
echo "https://preview-${PR_NUMBER}--reverent-murdock-829d24.netlify.app"
else
echo "No pull request detected. Preview link not available."
fi

npm install --save-dev netlify-cli@24.0.1
npx netlify deploy --no-build --alias=preview-${CIRCLE_PULL_REQUEST##*/} --filter @okta/vuepress-site --dir=packages/@okta/vuepress-site/dist

workflows:
linting:
when:
and:
- not: << pipeline.parameters.preview >>
- not: << pipeline.parameters.preview_with_redirect >>
jobs:
- inclusive-linting:
name: "Inclusive Linting"

build_checks:
when:
and:
- not: << pipeline.parameters.preview >>
- not: << pipeline.parameters.preview_with_redirect >>
jobs:
- node_build_checks:
name: "Build and Checks"
- snyk-scan:
context:
- static-analysis
name: execute-snyk
requires:
- Build and Checks
filters:
branches:
only:
- master

nightly:
triggers:
- schedule:
cron: "1 5 * * *"
filters:
branches:
only:
- master
jobs:
- nightly_link_checker:
name: "Nightly Link Checker"

netlify_manual:
wf_netlify_manual:
when: << pipeline.parameters.preview >>
jobs:
- netlify_manual:
name: "Netlify Manual"
- netlify_manual
- netlify_publish:
requires:
- netlify_manual

netlify_manual_with_redirects:
when: << pipeline.parameters.preview_with_redirect >>
jobs:
- netlify_manual_with_redirects:
name: "Netlify Manual With Redirects"
1 change: 1 addition & 0 deletions packages/@okta/vuepress-site/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vercel