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

feat: output docs into versioned subfolder #30

Merged
merged 8 commits into from
Nov 15, 2020
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
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@ jobs:
- name: Check links ⚓️
run: npm run check:links

- name: Set Cypress version 🎁
id: cypress
run: echo "::set-output name=version::$(node ./src/print-cypress-version)"

- name: Print Cypress version 🖨
run: echo "Cypress version is ${{ steps.cypress.outputs.version }}"

- name: Build site 🏗
run: npm run docs:build

- name: Export Markdown specs 🖨
run: node ./md-to-js http://localhost:5000/cypress-examples
run: node ./md-to-js http://localhost:5000/cypress-examples/${{ steps.cypress.outputs.version }}

- name: Catch stray .only tests 🚦
run: npm run stop-only
Expand Down Expand Up @@ -65,4 +72,5 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public/cypress-examples
publish_dir: ./public/cypress-examples/${{ steps.cypress.outputs.version }}"
destination_dir: ${{ steps.cypress.outputs.version }}"
11 changes: 9 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: pr
# test Cypress examples on every pull request
# and make sure the site builds, but no deploy
on: pull_request
Expand All @@ -12,6 +12,13 @@ jobs:
with:
persist-credentials: false

- name: Set Cypress version 🎁
id: cypress
run: echo "::set-output name=version::$(node ./src/print-cypress-version)"

- name: Print Cypress version 🖨
run: echo "Cypress version is ${{ steps.cypress.outputs.version }}"

- name: Cypress tests 🧪
uses: cypress-io/github-action@v2
with:
Expand All @@ -24,7 +31,7 @@ jobs:
run: npm run docs:build

- name: Export Markdown specs 🖨
run: node ./md-to-js http://localhost:5000/cypress-examples
run: node ./md-to-js http://localhost:5000/cypress-examples/${{ steps.cypress.outputs.version }}

- name: Catch stray .only tests 🚦
run: npm run stop-only
Expand Down
15 changes: 12 additions & 3 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
let _highlight

const { findCypressVersion } = require('../../src/utils')
const path = require('path')

const cypressVersion = findCypressVersion()
const base = `/cypress-examples/${cypressVersion}/`
const dest = path.join('public', 'cypress-examples', cypressVersion)
console.log('output folder: %s', dest)
const title = `Cypress examples (v${cypressVersion})`

module.exports = {
title: 'Cypress examples',
title,
description:
'Static site with Cypress examples tested right from the Markdown sources',
base: '/cypress-examples/',
dest: 'public/cypress-examples',
base,
dest,
head: [
[
'link',
Expand Down
2 changes: 1 addition & 1 deletion docs/commands/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ To visit a remote page, use the `cy.visit()` command.
// trick: dynamically set base url in this test only
Cypress.config(
'baseUrl',
window.location.origin + '/cypress-examples',
`${window.location.origin}/cypress-examples/${Cypress.version}`,
)

// Visit any sub-domain of your current domain,
Expand Down
4 changes: 3 additions & 1 deletion md-to-js.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// @ts-check
const shell = require('shelljs')
const path = require('path')
const { findCypressVersion } = require('./src/utils')

// converts Markdown fiddle specs into JavaScript specs
let baseUrl = process.argv[2]
if (!baseUrl) {
const DEFAULT_BASE_URL = 'http://localhost:5000/cypress-examples'
const cypressVersion = findCypressVersion()
const DEFAULT_BASE_URL = `http://localhost:5000/cypress-examples/${cypressVersion}`
console.log('Setting empty baseUrl to %s', DEFAULT_BASE_URL)
baseUrl = DEFAULT_BASE_URL
}
Expand Down
Loading