2021-05-21 19:31:25 +02:00
|
|
|
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 }}
|
2021-05-21 22:36:45 +02:00
|
|
|
AWS_DEFAULT_REGION: "us-east-1"
|
2021-05-21 19:31:25 +02:00
|
|
|
|
|
|
|
steps:
|
2021-05-21 22:55:50 +02:00
|
|
|
- name: Set Version
|
2021-05-21 19:31:25 +02:00
|
|
|
id: vars
|
2021-05-21 22:58:36 +02:00
|
|
|
run: |
|
|
|
|
tag=${GITHUB_REF#refs/*/}
|
|
|
|
[ "$tag" = "main" ] && echo ::set-output name=tag::devel || echo ::set-output name=tag::$tag
|
2021-05-21 19:31:25 +02:00
|
|
|
|
|
|
|
# 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
|
|
|
|
#################################################################
|
|
|
|
|
2021-05-21 22:55:50 +02:00
|
|
|
# deploy the site in the right foder ( tag or devel)
|
2021-05-21 19:31:25 +02:00
|
|
|
- name: S3 Sync
|
|
|
|
uses: ItsKarma/aws-cli@v1.70.0
|
|
|
|
with:
|
2021-05-21 20:24:22 +02:00
|
|
|
args: s3 sync --delete ./tools/gendocs/public/ s3://docs.dagger.io/${{steps.vars.outputs.tag}}/
|
2021-05-21 19:31:25 +02:00
|
|
|
|
|
|
|
# list All Tags in json file for version selector
|
|
|
|
# upload to /tags.json
|
|
|
|
- name: Create tags.json
|
2021-05-21 22:55:50 +02:00
|
|
|
run: echo "[" {\"tag\"':' \"$(git tag -l "v*" | tr '\n' '|' | sed -e 's/|/"}, {\"tag\"':' "/g')devel\"} "]" > tags.json
|
2021-05-21 19:31:25 +02:00
|
|
|
- name: Copy tags.json
|
|
|
|
uses: ItsKarma/aws-cli@v1.70.0
|
|
|
|
with:
|
2021-05-21 20:24:22 +02:00
|
|
|
args: s3 cp ./tags.json s3://docs.dagger.io/
|
2021-05-21 19:31:25 +02:00
|
|
|
|
|
|
|
# landing alway on latest tag
|
|
|
|
# use S3 Rediret objet
|
|
|
|
# upload to /docs/index.html
|
2021-05-27 23:48:54 +02:00
|
|
|
- name: Create index.html
|
|
|
|
run: |
|
|
|
|
cat <<EOF > index.html
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="refresh" content="0; url=/${{steps.vars.outputs.tag}}">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
Nothing to see here; <a href="/${{steps.vars.outputs.tag}}">see the
|
|
|
|
latest version of the docs</a>.
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|
|
|
|
- name: Copy index.html
|
|
|
|
if: ${{ steps.vars.outputs.tag != 'devel' }}
|
2021-05-21 19:31:25 +02:00
|
|
|
uses: ItsKarma/aws-cli@v1.70.0
|
|
|
|
with:
|
2021-05-27 23:48:54 +02:00
|
|
|
args: s3 cp --cache-control max-age=0 ./index.html s3://docs.dagger.io/
|