Skip to content

Commit

Permalink
docs: PR preview (#194)
Browse files Browse the repository at this point in the history
## 馃摐 Description

Added an ability to preview PRs.

## 馃挕 Motivation and Context

Sometimes it's easier to review PR when it's deployed (check how it
looks on mobile devices etc.).

The list below is important to take into consideration when PR will be
merged:

- don't remove pr-review directory in main deployment pipeline
- remove preview when PR was closed/merged (.nojekyl?)
- be sure that there is no race condition, when PR is getting merged

## 馃摙 Changelog

### CI
- added new job which deploys preview to github pages;

### Docs
- conditionally change `baseUrl` to handle case for previews;

## 馃 How Has This Been Tested?

Tested using GitHub actions.

## 馃摑 Checklist

- [x] CI successfully passed
  • Loading branch information
kirillzyusko committed Jul 25, 2023
1 parent 95a5376 commit 44eb328
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .github/workflows/verify-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
paths:
- '.github/workflows/verify-docs.yml'
- 'docs/**'
types:
- opened
- reopened
- synchronize
- closed

jobs:
build:
Expand Down Expand Up @@ -41,3 +46,24 @@ jobs:
run: yarn install --frozen-lockfile
- name: Run Lint
run: yarn markdownlint-cli2 "**/*.md" "#node_modules"
preview:
runs-on: ubuntu-latest
name: 馃洬 Deploy preview
defaults:
run:
working-directory: docs
steps:
- uses: actions/checkout@v3
- run: echo "PREVIEW_PATH=pr-preview/pr-${{ github.event.number }}" >> "$GITHUB_ENV"
- uses: actions/setup-node@v3
with:
node-version: 16.x
cache: yarn
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build website
run: yarn build
- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./docs/build/
5 changes: 4 additions & 1 deletion docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/dracula');

let baseUrl = '/react-native-keyboard-controller/';
if (process.env.PREVIEW_PATH) baseUrl += process.env.PREVIEW_PATH;

/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Keyboard Controller',
tagline: 'Control each frame of keyboard movement in react native',
url: 'https://kirillzyusko.github.io',
baseUrl: '/react-native-keyboard-controller/',
baseUrl: baseUrl,
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
favicon: 'img/favicon.ico',
Expand Down

0 comments on commit 44eb328

Please sign in to comment.