f8f100633f
Reviewed-on: #2 Co-authored-by: Arswarog <arswarog@yandex.ru> Co-committed-by: Arswarog <arswarog@yandex.ru>
113 lines
3.6 KiB
YAML
113 lines
3.6 KiB
YAML
name: 'Docusaurus Deploy'
|
|
description: 'Builds Docusaurus docs from repo and deploys to S3'
|
|
|
|
inputs:
|
|
docs-path:
|
|
description: 'Path to docs directory in calling repo'
|
|
default: 'docs'
|
|
on-broken-links:
|
|
description: 'Behavior on broken links: throw, warn, or ignore'
|
|
default: 'throw'
|
|
|
|
runs:
|
|
using: 'composite'
|
|
steps:
|
|
- name: Compute target URL
|
|
shell: bash
|
|
run: |
|
|
REF="${{ github.head_ref || github.ref_name }}"
|
|
REPO="${{ github.event.repository.name }}"
|
|
ORG="${{ github.repository_owner }}"
|
|
|
|
if [[ "$REF" == "main" || "$REF" == "master" ]]; then
|
|
URL="http://${REPO}.${ORG}.jt4d-wiki.ru.net"
|
|
S3_PATH="${ORG}.${REPO}"
|
|
else
|
|
URL="http://${REF}.${REPO}.${ORG}.jt4d-wiki.ru.net"
|
|
S3_PATH="${ORG}.${REPO}.${REF}"
|
|
fi
|
|
|
|
echo "TARGET_URL=$URL" >> $GITHUB_ENV
|
|
echo "S3_PATH=$S3_PATH" >> $GITHUB_ENV
|
|
|
|
- name: Set docs status pending
|
|
shell: bash
|
|
run: |
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${{ github.token }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"state": "pending",
|
|
"context": "Docs",
|
|
"description": "building",
|
|
"target_url": "${{ env.TARGET_URL }}"
|
|
}' \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/statuses/${{ github.sha }}"
|
|
|
|
- name: Copy docs into Docusaurus
|
|
shell: bash
|
|
run: |
|
|
DOCUSAURUS_DIR="${{ github.action_path }}"
|
|
rm -rf "${DOCUSAURUS_DIR}/docs"
|
|
cp -r "${{ inputs.docs-path }}" "${DOCUSAURUS_DIR}/docs"
|
|
cp "${{ github.workspace }}/.docuservix.yml" "${DOCUSAURUS_DIR}"
|
|
|
|
- name: Prepare docs
|
|
shell: bash
|
|
working-directory: ${{ github.action_path }}
|
|
run: node scripts/prepare-docs.mjs
|
|
|
|
- name: Install Docusaurus dependencies
|
|
shell: bash
|
|
working-directory: ${{ github.action_path }}
|
|
run: yarn install --frozen-lockfile
|
|
|
|
- name: Build docs
|
|
shell: bash
|
|
working-directory: ${{ github.action_path }}
|
|
env:
|
|
DOCUSERVIX_ON_BROKEN_LINKS: ${{ inputs.on-broken-links }}
|
|
DOCUSERVIX_URL: ${{ env.TARGET_URL }}
|
|
run: yarn docusaurus build --out-dir ${{ github.workspace }}/generated-docs
|
|
|
|
- name: Upload to S3
|
|
shell: bash
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ vars.DOCUSERVIX_S3_ACCESS }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ vars.DOCUSERVIX_S3_SECRET }}
|
|
run: |
|
|
aws s3 sync generated-docs/ \
|
|
s3://${{ vars.DOCUSERVIX_S3_BUCKET }}/${{ env.S3_PATH }}\
|
|
--endpoint-url ${{ vars.DOCUSERVIX_S3_URL }} \
|
|
--acl public-read \
|
|
--delete
|
|
|
|
- name: Set docs status success
|
|
if: success()
|
|
shell: bash
|
|
run: |
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${{ github.token }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"state": "success",
|
|
"context": "Docs",
|
|
"description": "deployed",
|
|
"target_url": "${{ env.TARGET_URL }}"
|
|
}' \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/statuses/${{ github.sha }}"
|
|
|
|
- name: Set docs status failure
|
|
if: failure()
|
|
shell: bash
|
|
run: |
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${{ github.token }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"state": "failure",
|
|
"context": "Docs",
|
|
"description": "build failed",
|
|
"target_url": "${{ env.TARGET_URL }}"
|
|
}' \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/statuses/${{ github.sha }}" |