Skip to content

Deploy internals on prod and test environments #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/deloy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Deploy

on:
workflow_dispatch:
push:
branches:
- master
jobs:
deploy:
runs-on: ['self-hosted', 'Linux', 'flavor-8-16']
container: tarantool/doc-builder:slim-4.2
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
AWS_DEFAULT_REGION: ${{secrets.AWS_DEFAULT_REGION}}
S3_ENDPOINT_URL: ${{secrets.S3_ENDPOINT_URL}}
S3_UPLOAD_PATH: ${{secrets.S3_UPLOAD_PATH}}
S3_BUCKET: ${{secrets.S3_BUCKET}}
INTERNALS_UPDATE_URL: ${{secrets.INTERNALS_UPDATE_URL}}
INTERNALS_UPDATE_KEY: ${{secrets.INTERNALS_UPDATE_KEY}}
BRANCH_NAME: latest
steps:
- uses: actions/checkout@v2

- run: sphinx-build -b json source -d build/.doctrees build/json
- run: bash upload_output.sh
9 changes: 4 additions & 5 deletions .github/workflows/deploy-branch.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Deploy-branch

name: Deploy branch
on:
pull_request:
jobs:
Expand All @@ -13,11 +12,11 @@ jobs:
ENDPOINT_URL: ${{secrets.ENDPOINT_URL}}
S3_UPLOAD_PATH: ${{secrets.S3_UPLOAD_PATH}}
S3_BUCKET: ${{secrets.S3_BUCKET}}
INTERNALS_UPDATE_URL: ${{secrets.INTERNALS_DEVELOP_UPDATE_URL}}
INTERNALS_UPDATE_KEY: ${{secrets.INTERNALS_UPDATE_KEY}}
BRANCH_NAME: test
steps:
- uses: actions/checkout@v2

- name: Set branch name from source branch
run: echo "BRANCH_NAME=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV

- run: sphinx-build -b json source -d build/.doctrees build/json
- run: bash upload_output.sh
20 changes: 14 additions & 6 deletions upload_output.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
#!/usr/bin/env bash


BRANCH=$BRANCH_NAME
DOC_DEST="$S3_UPLOAD_PATH/internals/${BRANCH_NAME}"
CHECK_KEY="doc-builds/internals/${BRANCH_NAME}/json/_build_ru/json/toctree.fjson"
# version in doc project and scripts
DOC_VERSION=latest
CHECK_KEY="doc-builds/internals/${BRANCH_NAME}/json/_build_en/json/toctree.fjson"
UPDATE_KEY=$INTERNALS_UPDATE_KEY
UPDATE_URL=$INTERNALS_UPDATE_URL

aws s3api head-object --bucket ${S3_BUCKET} --key ${CHECK_KEY} --endpoint-url="$ENDPOINT_URL" || not_exist=true
aws s3api head-object --bucket ${S3_BUCKET} --key ${CHECK_KEY} --endpoint-url="${ENDPOINT_URL}" || not_exist=true
if [ $not_exist ]; then
echo "toctree.json does not exist"
else
echo "found toctree.json, remove the branch from s3 location"
aws s3 rm "$DOC_DEST"/json --endpoint-url="$ENDPOINT_URL" --recursive
aws s3 rm "${DOC_DEST}"/json --endpoint-url="${ENDPOINT_URL}" --recursive
fi

aws s3 cp build/json "$DOC_DEST"/json --endpoint-url="$ENDPOINT_URL" --recursive --include "*" --exclude "*.jpg" --exclude "*.png" --exclude "*.svg"
aws s3 cp build/json "${DOC_DEST}"/json/_build_en/json --endpoint-url="${ENDPOINT_URL}" --recursive --include "*" --exclude "*.jpg" --exclude "*.png" --exclude "*.svg"

set -xe
curl --fail --show-error \
--data '{"update_key":"'"${UPDATE_KEY}"'"}' \
--header "Content-Type: application/json" \
--request POST "${UPDATE_URL}""${DOC_VERSION}"/