docs: move gendocs tool to dagger/dagger

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-05-21 10:31:25 -07:00
parent b9083f7fea
commit 6ddb973f03
25 changed files with 15314 additions and 141 deletions

View File

@@ -1,101 +0,0 @@
# This is a basic workflow to help you get started with Actions
name: DEPLOY
# Controls when the action will run.
on:
push:
branches:
- main
tags:
- v*
paths:
- 'doc/**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "eu-west-1"
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
#################################################################
# COMMOMS
#################################################################
# Get current tag (or 'main') in step output for use in uploads
- name: Set Tag Name
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
#################################################################
# FETCH GENERATOR + DATA
#################################################################
# fetch gatsby generator from 'dagger/DocGenerator'
# then fetch docs data to have generator + data in the context of the job
# fetch-depth: '0' enables listing all tags for version selector
- uses: actions/checkout@v2
with:
repository: 'dagger/DocGenerator'
ref: 'main'
token: ${{ secrets.PAT }} # is a secret that contains your PAT
- uses: actions/checkout@v2
with:
fetch-depth: '0'
path: 'docsTMP'
- run: mkdir -p docs && mv docsTMP/docs/* docs/
- run: mv ./docs/index.mdx ./src/@rocketseat/gatsby-theme-docs/text/index.mdx
#################################################################
# BUILD SITE
#################################################################
# Install Node
- uses: actions/setup-node@v2
with:
node-version: "14"
- run: yarn
- name: Build Site
run: yarn build --prefix-paths
env:
VERSION: ${{steps.vars.outputs.tag}}
#################################################################
# DEPLOY TO S3
#################################################################
# deploy the site in the right foder ( tag or main)
- name: S3 Sync
uses: ItsKarma/aws-cli@v1.70.0
with:
args: s3 sync --delete --acl public-read public/ s3://daggerdoc.humans-it.com/docs/${{steps.vars.outputs.tag}}/
# list All Tags in json file for version selector
# upload to /tags.json
- name: Create tags.json
run: echo "[" {\"tag\"':' \"$(git --git-dir ./docsTMP/.git tag -l "v*" | tr '\n' '|' | sed -e 's/|/"}, {\"tag\"':' "/g')main\"} "]" > tags.json
- name: Copy tags.json
uses: ItsKarma/aws-cli@v1.70.0
with:
args: s3 cp --acl public-read ./tags.json s3://daggerdoc.humans-it.com/
# landing alway on latest tag
# use S3 Rediret objet
# upload to /docs/index.html
- run: touch index.html
- name: Redirect Latest tag on landing
if: ${{ steps.vars.outputs.tag != 'main' }}
uses: ItsKarma/aws-cli@v1.70.0
with:
args: s3 cp --cache-control max-age=0 --acl public-read --website-redirect /docs/${{steps.vars.outputs.tag}}/ ./index.html s3://daggerdoc.humans-it.com/docs/

78
.github/workflows/docs.yml vendored Normal file
View File

@@ -0,0 +1,78 @@
name: Docs
on:
push:
branches:
- main
tags:
- v*
paths:
- "docs/**"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "eu-west-1"
steps:
- name: Set Tag Name
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
# fetch-depth: '0' enables listing all tags for version selector
- uses: actions/checkout@v2
with:
fetch-depth: "0"
#################################################################
# BUILD SITE
#################################################################
# Install Node
- uses: actions/setup-node@v2
with:
node-version: "14"
- run: yarn --cwd ./tools/gendocs
- name: Build Site
run: yarn --cwd ./tools/gendocs build --prefix-paths
env:
VERSION: ${{steps.vars.outputs.tag}}
#################################################################
# DEPLOY TO S3
#################################################################
# deploy the site in the right foder ( tag or main)
- name: S3 Sync
uses: ItsKarma/aws-cli@v1.70.0
with:
args: s3 sync --delete --acl public-read ./tools/gendocs/public/ s3://daggerdoc.humans-it.com/${{steps.vars.outputs.tag}}/
# list All Tags in json file for version selector
# upload to /tags.json
- name: Create tags.json
run: echo "[" {\"tag\"':' \"$(git tag -l "v*" | tr '\n' '|' | sed -e 's/|/"}, {\"tag\"':' "/g')main\"} "]" > tags.json
- name: Copy tags.json
uses: ItsKarma/aws-cli@v1.70.0
with:
args: s3 cp --acl public-read ./tags.json s3://daggerdoc.humans-it.com/
# landing alway on latest tag
# use S3 Rediret objet
# upload to /docs/index.html
- run: touch index.html
- name: Redirect Latest tag on landing
# FIXME
# if: ${{ steps.vars.outputs.tag != 'main' }}
uses: ItsKarma/aws-cli@v1.70.0
with:
# FIXME: `--website-redirect` uses a permanent redirect, therefore if
# we use the latest version it will be in cache forever.
# args: s3 cp --cache-control max-age=0 --acl public-read --website-redirect /docs/${{steps.vars.outputs.tag}}/ ./index.html s3://daggerdoc.humans-it.com/docs/
args: s3 cp --cache-control max-age=0 --acl public-read --website-redirect /main/ ./index.html s3://daggerdoc.humans-it.com/