Skip to content

Commit

Permalink
Docusaurus skeleton (#54)
Browse files Browse the repository at this point in the history
* Removed legacy Gatsby site files

* Initial Docusaurus skeleton

* Deleted unneeded README

* Update to exclude docusaurus build and internal directories

* Added scripts to push to S3

* Added CircleCI config to begin setting up CI/CD for stage being auto-deployed from commits to main/master branch
  • Loading branch information
eak12913 authored Nov 9, 2021
1 parent becec7b commit 1411237
Show file tree
Hide file tree
Showing 253 changed files with 7,181 additions and 22,284 deletions.
23 changes: 23 additions & 0 deletions .circleci/aws/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[default]
region=us-east-1
output=json

[profile dogfood-dev]
region=us-east-1
credential_source=Environment
role_arn=arn:aws:iam::090304172891:role/allow-gruntwork-website-ci-cd-access-from-other-accounts

[profile dogfood-stage]
region=us-east-1
credential_source=Environment
role_arn=arn:aws:iam::151025255439:role/allow-gruntwork-website-ci-cd-access-from-other-accounts

[profile dogfood-prod]
region=us-east-1
credential_source=Environment
role_arn=arn:aws:iam::996502968539:role/allow-gruntwork-website-ci-cd-access-from-other-accounts

[profile dogfood-shared]
region=us-east-1
credential_source=Environment
role_arn=arn:aws:iam::706132791050:role/allow-gruntwork-website-ci-cd-access-from-other-accounts
102 changes: 102 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
version: 2.1

######################################################################################################################
# Define the ORBS we'll use in the rest of the workflow
######################################################################################################################
orbs:
docker: circleci/[email protected]
awscli: circleci/[email protected]
slack: circleci/[email protected]

######################################################################################################################
# We define all the actual build steps here in named, reusable references. This allows us to define jobs below as a
# readable, composable list of references
######################################################################################################################
references:
base_container: &base_container
docker:
- image: circleci/node:14.15

######################################################################################################################
# Build steps
######################################################################################################################

deploy_to_staging: &deploy-to-staging
run:
name: deploy to staging
command: |
set +o pipefail
export CREDENTIALS=`aws sts assume-role --role-arn arn:aws:iam::151025255439:role/allow-gruntwork-website-ci-cd-access-from-other-accounts --role-session-name CircleCI --duration-seconds 900 --output=json`
export AWS_ACCESS_KEY_ID=`echo ${CREDENTIALS} | jq -r '.Credentials.AccessKeyId'`
export AWS_SECRET_ACCESS_KEY=`echo ${CREDENTIALS} | jq -r '.Credentials.SecretAccessKey'`
export AWS_SESSION_TOKEN=`echo ${CREDENTIALS} | jq -r '.Credentials.SessionToken'`
export AWS_EXPIRATION=`echo ${CREDENTIALS} | jq -r '.Credentials.Expiration'`
./scripts/push-to-s3-stage.sh
deploy_to_prod: &deploy-to-prod
run:
name: deploy to prod
command: |
set +o pipefail
export CREDENTIALS=`aws sts assume-role --role-arn arn:aws:iam::996502968539:role/allow-gruntwork-website-ci-cd-access-from-other-accounts --role-session-name CircleCI --duration-seconds 900 --output=json`
export AWS_ACCESS_KEY_ID=`echo ${CREDENTIALS} | jq -r '.Credentials.AccessKeyId'`
export AWS_SECRET_ACCESS_KEY=`echo ${CREDENTIALS} | jq -r '.Credentials.SecretAccessKey'`
export AWS_SESSION_TOKEN=`echo ${CREDENTIALS} | jq -r '.Credentials.SessionToken'`
export AWS_EXPIRATION=`echo ${CREDENTIALS} | jq -r '.Credentials.Expiration'`
./scripts/push-to-s3-prod.sh
notify_slack_staging: &notify_slack_staging
slack/status:
failure_message: ":red_circle: $CIRCLE_JOB has failed on master! Build triggered by: $CIRCLE_USERNAME. You have one hour to fix or revert!!"
success_message: ":tada: [Stage] Docs site has been successfully deployed at version $CIRCLE_SHA1 to https://docs.dogfood-stage.com"
only_for_branches: "master"
channel: "C01J73HUKEF" # #team-platform-notifications

notify_slack_prod: &notify_slack_prod
slack/status:
failure_message: ":red_circle: $CIRCLE_JOB has failed on master! Build triggered by: $CIRCLE_USERNAME. You have one hour to fix or revert!!"
success_message: ":tada: [Prod] Docs site has been successfully deployed at version $CIRCLE_TAG to https://docs.gruntwork.io"
channel: "C01J73HUKEF" # #team-platform-notifications

#######################################################################################################################
# The build jobs available, all consisting of lists of references to the references section above
#######################################################################################################################
jobs:
deploy-to-stage:
<<: *base_container
description: Deploy to Staging
steps:
- checkout
- awscli/install
- *deploy-to-staging
- *notify_slack_staging

deploy-to-prod:
<<: *base_container
description: Deploy to Prod
steps:
- checkout
- awscli/install
- *deploy-to-prod
- *notify_slack_prod

# ---------------------------------------------------------------------------------------------------------------------
# Here we combine the jobs defined above into various workflows that can run in parallel or sequentially, define
# dependencies on each other, and only run on certain branches/tags.
# ---------------------------------------------------------------------------------------------------------------------

workflows:
version: 2
each_commit:
jobs:
- deploy-to-stage:
filters:
branches:
# TODO: UPDATE TO `main/master`
only: docusaurus
- deploy-to-prod:
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,6 @@ yarn-error.log
.pnp.js
# Yarn Integrity file
.yarn-integrity

build/
.docusaurus/
97 changes: 0 additions & 97 deletions README.gatsby.md

This file was deleted.

56 changes: 19 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,33 @@
# Generating Gruntwork Package and Module Documentation
# Website

This repo contains a set of tools for generating Gruntwork Package and Gruntwork Module documentation on a public website
in a customizable format.
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.

## Features
### Installation

This docs site is built using [Gatsby](https://www.gatsbyjs.org/), a static site generator that is based on React.
We have extended it using plugins and custom code to support all of the relevant features required, including:

- Syntax highlighting (via prismjs)
- Copy code to clipboard
- Image Captions
- Responsive design with fixed header
- Edit on GitHub buttons
- Google Analytics
- A dynamic sidebar with the ToC of the current page

## doc-sourcer

Some of the content is pulled from our other repos. You can look at `gruntyrepos.yml` for a list of repos where docs
are sourced.
```
$ yarn
```

This is managed through the `doc-sourcer` tool. Make sure you have a copy of it available by running:
### Local Development

```
(cd ./doc_sourcer && go build -o doc-sourcer .)
$ yarn start
```

**NOTE: The doc-sourcer project uses [go modules](https://github.com/golang/go/wiki/Modules). You may experience
dependency issues if you clone the repo in your GOPATH. To address, clone outside of the GOPATH.**
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

## Deploy
### Build

To deploy a new version of the site, run:

1. `./doc_sourcer/doc-sourcer`
1. `yarn run build`
1. `houston-cli exec websites -- yarn run deploy`
```
$ yarn build
```

### The Generation Workflow
This command generates static content into the `build` directory and can be served using any static contents hosting service.

Generating documentation is a multi-step process made up of the following stages:
### Deployment

1. `docs-fetcher`: Fetch all Gruntwork Package and Gruntwork Module source code into one repo.
2. `docs-preprocessor`: Transform the default folder structure of Gruntwork docs into a folder structure that mirrors
the desired public website structure.
3. `docs-generator`: Convert markdown files to HTML files, and generate an HTML-based navigation for all pages.
```
$ GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy
```

By using separate tools, we can compose this process to generate different kinds of documentation, pull from different
sources, or output in a different format.
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
Loading

0 comments on commit 1411237

Please sign in to comment.