Skip to content

Merge pull request #579 from kuzzleio/develop #160

Merge pull request #579 from kuzzleio/develop

Merge pull request #579 from kuzzleio/develop #160

# This is a basic workflow to help you get started with Actions
name: Deploy the whole documentation
on:
push:
branches: [master, develop]
workflow_dispatch:
env:
NODE_VERSION: 20
jobs:
prepare-matrix:
name: Prepare matrix by getting the repo names from repositories.json
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install yq
run: |
sudo apt-get update
sudo apt-get install python python3-pip
pip3 install yq
shell: bash
- name: Get repo names
id: set-matrix
run: |
export REPOS=$(cat .repos/repositories.json | yq -c '[.[]]')
echo "::set-output name=repo::$REPOS"
outputs:
matrix: ${{ steps.set-matrix.outputs.repo }}
deploy_framework:
name: Deploy framework
runs-on: ubuntu-20.04
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-west-1
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Deploy artefact for production
uses: ./.github/actions/deploy_fw_artifacts
if: ${{ github.ref == 'refs/heads/master' }}
with:
S3_BUCKET: s3://docs.kuzzle.io
CLOUDFRONT_ID: E3D6RP0POLCJMM
- name: Deploy artefact for staging
uses: ./.github/actions/deploy_fw_artifacts
if: ${{ github.ref != 'refs/heads/master' }}
with:
S3_BUCKET: s3://docs-next.kuzzle.io
CLOUDFRONT_ID: E2ZCCEK9GRB49U
deploy_child_repo:
name: Deploy child repo ${{ matrix.repo.repo_name }}-${{ matrix.repo.doc_version }}
needs: [prepare-matrix, deploy_framework]
runs-on: ubuntu-20.04
strategy:
matrix:
repo: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
fail-fast: false
steps:
- name: Recap of the build
run: echo "Build and deploy documentation for ${{ matrix.repo.repo_name }}-${{ matrix.repo.doc_version }}"
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa
known_hosts: unnecessary
- name: Deploy production matrice
uses: ./.github/actions/deploy_repo
if: ${{ github.ref == 'refs/heads/master' }}
with:
repo_name: ${{ matrix.repo.repo_name }}
repo_version: ${{ matrix.repo.doc_version }}
repo_branch: ${{ matrix.repo.stable }}
REGION: us-west-2
S3_BUCKET: docs.kuzzle.io
CLOUDFRONT_ID: E3D6RP0POLCJMM
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
NO_INVALIDATION: true
- name: Deploy staging matrice
uses: ./.github/actions/deploy_repo
if: ${{ github.ref != 'refs/heads/master' }}
with:
repo_name: ${{ matrix.repo.repo_name }}
repo_version: ${{ matrix.repo.doc_version }}
repo_branch: ${{ matrix.repo.dev }}
REGION: us-west-2
S3_BUCKET: docs-next.kuzzle.io
CLOUDFRONT_ID: E2ZCCEK9GRB49U
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
NO_INVALIDATION: true
invalidate_cloudfront:
name: Invalidate CloudFront
needs: [deploy_child_repo]
runs-on: ubuntu-20.04
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-west-1
steps:
- name: Invalidate CloudFront for next-docs.kuzzle.io
if: ${{ github.ref != 'refs/heads/master' }}
run: aws cloudfront create-invalidation --distribution-id E2ZCCEK9GRB49U --paths "/*"
- name: Invalidate CloudFront for docs.kuzzle.io
if: ${{ github.ref == 'refs/heads/master' }}
run: aws cloudfront create-invalidation --distribution-id E3D6RP0POLCJMM --paths "/*"