From 828f9d9ff105b8025150b1be91f022063d19ed01 Mon Sep 17 00:00:00 2001 From: slumbering Date: Fri, 21 May 2021 17:20:15 +0200 Subject: [PATCH] script deploy plugged to docGenerator repo + rename doc/ to docs/ Signed-off-by: slumbering --- .github/workflows/deploy.yml | 101 +++++++++++++++++++++++++++++++++++ .github/workflows/doc.yml | 29 ---------- {doc => docs}/01_overview.md | 0 {doc => docs}/install.md | 0 {doc => docs}/operator.md | 0 {doc => docs}/programming.md | 0 {doc => docs}/vs.md | 0 7 files changed, 101 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/doc.yml rename {doc => docs}/01_overview.md (100%) rename {doc => docs}/install.md (100%) rename {doc => docs}/operator.md (100%) rename {doc => docs}/programming.md (100%) rename {doc => docs}/vs.md (100%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..39cb104e --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,101 @@ +# 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/ diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml deleted file mode 100644 index 119057fa..00000000 --- a/.github/workflows/doc.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Doc - -on: - push: - branches: - - main - tags: - - v* - paths: - - "doc/**" - -jobs: - copy-file: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Pushes docs file - uses: dagger/doc_copy_action@main - env: - API_TOKEN_GITHUB: ${{ secrets.DAGGERCI_TOKEN }} - with: - source_file: "doc/." - destination_repo: "dagger/launch.dagger.io" - destination_folder: "site/doc" - user_email: "noreply@dagger.io" - user_name: "dagger-bot" diff --git a/doc/01_overview.md b/docs/01_overview.md similarity index 100% rename from doc/01_overview.md rename to docs/01_overview.md diff --git a/doc/install.md b/docs/install.md similarity index 100% rename from doc/install.md rename to docs/install.md diff --git a/doc/operator.md b/docs/operator.md similarity index 100% rename from doc/operator.md rename to docs/operator.md diff --git a/doc/programming.md b/docs/programming.md similarity index 100% rename from doc/programming.md rename to docs/programming.md diff --git a/doc/vs.md b/docs/vs.md similarity index 100% rename from doc/vs.md rename to docs/vs.md