From 05e55fa1713e21ebd4ed684f960952a25b86632a Mon Sep 17 00:00:00 2001 From: Arswarog Date: Sat, 13 Jun 2026 21:05:02 +0300 Subject: [PATCH] Initial commit --- action.yml | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..2197c3f --- /dev/null +++ b/action.yml @@ -0,0 +1,101 @@ +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' + +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}.docs.jt4d.ru.net" + else + URL="http://${REF}.${REPO}.${ORG}.docs.jt4d.ru.net" + fi + + echo "TARGET_URL=$URL" >> $GITHUB_ENV + echo "S3_PATH=${ORG}.${REPO}.${REF}" >> $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 }}docusaurus" + rm -rf "${DOCUSAURUS_DIR}/docs" + cp -r "${{ inputs.docs-path }}" "${DOCUSAURUS_DIR}/docs" + cp "${{ github.workspace }}/.docuservix.yml" "${DOCUSAURUS_DIR}" + + + - name: Install Docusaurus dependencies + shell: bash + working-directory: ${{ github.action_path }}docusaurus + run: yarn install --frozen-lockfile + + - name: Build docs + shell: bash + working-directory: ${{ github.action_path }}docusaurus + 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 }}/docs.${{ 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 }}" \ No newline at end of file