Skip to content

Commit

Permalink
Refarch (#563)
Browse files Browse the repository at this point in the history
Setup for reference architecture documentation
  • Loading branch information
Zinovii Dmytriv authored Mar 13, 2023
1 parent d67a18c commit 781a4d5
Show file tree
Hide file tree
Showing 17 changed files with 350 additions and 307 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/website-deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ jobs:
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: "Checkout 'terraform-aws-components' Repository"
uses: actions/checkout@v3
with:
Expand All @@ -62,33 +67,33 @@ jobs:
with:
python-version: '3.10'

- name: "Install deps"
- name: "Install Python Dependencies"
run: |
make init
pip install -r scripts/docs-collator/requirements.txt
- name: "Render docs for components"
- name: "Render Documentation for Terraform Components"
run: |
./scripts/render-docs-for-components.sh
- name: "Render docs for modules"
- name: "Render Documentation for Terraform Modules"
env:
PUBLIC_REPO_ACCESS_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
PUBLIC_REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
run: |
./scripts/render-docs-for-modules.sh
- name: "Render Documentation for GitHub Actions"
env:
PUBLIC_REPO_ACCESS_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
PUBLIC_REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
run: |
./scripts/render-docs-for-github-actions.sh
- name: Install Dependencies and Build Website
env:
GOOGLE_TAG_MANAGER: GTM-ABCD123
run: |
make deps-production
make build
make init
make build-production
- name: Copy Website to S3 Bucket PR Folder
run: |
Expand Down
90 changes: 9 additions & 81 deletions .github/workflows/website-deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,92 +10,20 @@ on:
types:
- published

env:
AWS_REGION: us-east-2
IAM_ROLE_ARN: arn:aws:iam::557075604627:role/cplive-plat-ue2-prod-cloudposse-docs-gha
IAM_ROLE_SESSION_NAME: cloudposse-docs-ci-deploy-release
S3_BUCKET_NAME: cplive-plat-ue2-prod-cloudposse-docs-origin
DEPLOYMENT_HOST: docs.cloudposse.com
ALGOLIA_INDEX_NAME: docs.cloudposse.com
ALGOLIA_APP_ID: 32YOERUX83

# These permissions are needed to interact with the GitHub's OIDC Token endpoint
permissions:
id-token: write
contents: read

jobs:
website-deploy-release:
trigger_documentation_deployment:
runs-on: ubuntu-latest

environment:
name: production
url: https://${{ env.DEPLOYMENT_HOST }}
url: https://docs.cloudposse.com

steps:
# https://github.com/marketplace/actions/configure-aws-credentials-action-for-github-actions
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ env.IAM_ROLE_ARN }}
role-session-name: ${{ env.IAM_ROLE_SESSION_NAME }}

- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: "Checkout 'terraform-aws-components' Repository"
uses: actions/checkout@v3
with:
fetch-depth: 1
repository: cloudposse/terraform-aws-components
ref: master
path: tmp/components/terraform-aws-components

- name: "Setup Python"
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: "Install deps"
run: |
make init
pip install -r scripts/docs-collator/requirements.txt
- name: "Render Documentation for Terraform Components"
run: |
./scripts/render-docs-for-components.sh
- name: "Render Documentation for Terraform Modules"
env:
PUBLIC_REPO_ACCESS_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
run: |
./scripts/render-docs-for-modules.sh
- name: "Render Documentation for GitHub Actions"
env:
PUBLIC_REPO_ACCESS_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
run: |
./scripts/render-docs-for-github-actions.sh
- name: Install Dependencies and Build Website
env:
GOOGLE_TAG_MANAGER: ${{ vars.GOOGLE_TAG_MANAGER }}
run: |
make deps-production
make build
- name: Copy Website to S3 Bucket
run: |
cd build
aws sts get-caller-identity
aws s3 sync . s3://${{ env.S3_BUCKET_NAME }} --delete
aws s3 ls s3://${{ env.S3_BUCKET_NAME }} --recursive --human-readable --summarize
- name: ReIndex with Algolia
env:
ALGOLIA_SCRAPER_API_KEY: ${{ secrets.ALGOLIA_SCRAPER_API_KEY }}
- name: Trigger Documentation Deployment
run: |
./algolia/reindex.sh
curl \
-X POST \
-H "Authorization: Bearer ${{ secrets.TRIGGER_DOCS_REDEPLOY_WORKFLOW_REFARCH }}" \
-H "Accept: application/vnd.github.everest-preview+json" \
https://api.github.com/repos/cloudposse/refarch-scaffold/dispatches \
-d '{"event_type": "redeploy_documentation"}'
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ algolia.index.json
content/components/catalog/aws/**
content/modules/catalog/**
content/github-actions/catalog/actions/**
content/reference-architecture/**
static/assets/refarch/**
!content/reference-architecture/reference-architecture-overview.md
!content/reference-architecture/refarch.json
!content/reference-architecture/sitemap.xml
32 changes: 15 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
SHELL := /bin/bash

export COMPONENTS_DIR ?= content/components
export DOCUSAURUS_PORT ?= 3000

export DOCKER_ORG ?= cloudposse
export DOCKER_IMAGE ?= $(DOCKER_ORG)/docs
export DOCKER_TAG ?= latest
export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG)
export DOCKER_BUILD_FLAGS =
export DOCKER_RUN_FLAGS ?= --rm
export DOCKER_RUN ?= docker run $(DOCKER_RUN_FLAGS) -v $(CURDIR):/src -p $(DOCUSAURUS_PORT):$(DOCUSAURUS_PORT) $(DOCKER_IMAGE_NAME)

-include $(shell curl -sSL -o .build-harness "https://cloudposse.tools/build-harness"; echo .build-harness)

.DEFAULT_GOAL := all

all: real-clean build
@exit 0

deps: docker/build
$(DOCKER_RUN) npm install

deps-production: docker/build
$(DOCKER_RUN) npm install --only=production
deps:
npm install --only=production

.PHONY: build

build: deps
$(DOCKER_RUN) npm run build
npm run build

# removed all files from `assets/js/*.js` and made 2 new special files `main.*.js` and `runtime~main.*.js`. This way we will not gonna get 404 by browser and page will load faster.
build-production: build
ASSETS_DIR="build/assets/js" && \
ASSETS_MAIN_FILE="$$(ls -1 $${ASSETS_DIR}/main.*.js)" && \
ASSETS_RUNTIME_MAIN_FILE="$$(ls -1 $${ASSETS_DIR}/runtime~main.*.js)" && \
rm -rf $${ASSETS_DIR}/* && \
touch $${ASSETS_MAIN_FILE} && \
touch $${ASSETS_RUNTIME_MAIN_FILE}

start:
npm start

start-production:
npm run serve

real-clean:
rm -fr .docusaurus && \
rm -fr build && \
Expand Down
4 changes: 4 additions & 0 deletions algolia/reindex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
ALGOLIA_INDEX_NAME=${ALGOLIA_INDEX_NAME:-test}
DEPLOYMENT_HOST=${DEPLOYMENT_HOST:-'docs.cloudposse.com'}
ALGOLIA_APP_ID=${ALGOLIA_APP_ID:-'32YOERUX83'}
ALGOLIA_CRAWLER_USER=${ALGOLIA_CRAWLER_USER:-test}
ALGOLIA_CRAWLER_PASSWORD=${ALGOLIA_CRAWLER_PASSWORD:-test}

[ -z "$ALGOLIA_SCRAPER_API_KEY" ] && echo "Need to set ALGOLIA_SCRAPER_API_KEY" && exit 1;

Expand All @@ -19,5 +21,7 @@ cat algolia.index.json
docker run \
--env APPLICATION_ID="${ALGOLIA_APP_ID}" \
--env API_KEY="${ALGOLIA_SCRAPER_API_KEY}" \
--env DOCSEARCH_BASICAUTH_USERNAME="${ALGOLIA_CRAWLER_USER}" \
--env DOCSEARCH_BASICAUTH_PASSWORD="${ALGOLIA_CRAWLER_PASSWORD}" \
--env "CONFIG=$(cat algolia.index.json | jq -r tostring)" \
algolia/docsearch-scraper
7 changes: 7 additions & 0 deletions content/account/confirmation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Account Confirmation
---

# Account Confirmation

Your registration must be approved by an administrator.
7 changes: 7 additions & 0 deletions content/account/email_verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Email Verification
---

# Email Verification

Please verify your email in order to proceed.
Empty file.
1 change: 1 addition & 0 deletions content/reference-architecture/refarch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "Reference Architecture Overview"
sidebar_position: 100
---

# Reference Architecture Overview

5 changes: 5 additions & 0 deletions content/reference-architecture/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
</urlset>
31 changes: 30 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check

const { redirects } = require("./redirects");
const lightCodeTheme = require('prism-react-renderer/themes/vsDark');
const darkCodeTheme = require('prism-react-renderer/themes/nightOwl');

Expand Down Expand Up @@ -54,6 +54,29 @@ const config = {
sidebarPath: require.resolve('./sidebars-github-actions.js')
},
],
[
'@docusaurus/plugin-content-docs',
{
id: 'reference-architecture',
path: 'content/reference-architecture',
routeBasePath: 'reference-architecture/',
sidebarPath: require.resolve('./sidebars-refarch.js')
},
],
[
'@docusaurus/plugin-content-pages',
{
id: 'account',
path: 'content/account/',
routeBasePath: 'account/'
},
],
[
'@docusaurus/plugin-client-redirects',
{
redirects
},
],
[
"@docusaurus/plugin-google-gtag",
{
Expand Down Expand Up @@ -134,6 +157,12 @@ const config = {
position: 'left',
label: 'GitHub Actions',
},
{
href: '/reference-architecture/reference-architecture-overview/',
position: 'left',
html: 'Reference Architecture',
target: '_self',
},
{
type: 'dropdown',
label: 'Community',
Expand Down
Loading

0 comments on commit 781a4d5

Please sign in to comment.