diff --git a/.github/workflows/deploy-docs-site.yml b/.github/workflows/deploy-docs-site.yml index 4da11c12fa2f..5b6a7b331565 100644 --- a/.github/workflows/deploy-docs-site.yml +++ b/.github/workflows/deploy-docs-site.yml @@ -7,13 +7,20 @@ on: paths: - "docs/**" + pull_request: + types: + - opened + - reopened + - synchronize + paths: + - "docs/**" + # Allows you to run this workflow manually from the Actions tab workflow_dispatch: jobs: - dummy-job: - name: Deploy Docs Assets - if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' + build-and-deploy-docs: + name: Build and Deploy Docs Assets runs-on: ubuntu-latest steps: - name: Check out the repository @@ -29,22 +36,47 @@ jobs: cache: "yarn" cache-dependency-path: docusaurus + - name: Run Docusaurus env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./tools/bin/deploy_docusaurus + run: |- + export SKIP_DEPLOY="yes" + if [ "${{github.event_name}}" = 'push' -o "${{github.event_name}}" = 'workflow_dispatch' ]; then + export SKIP_DEPLOY="no" + fi + + ./tools/bin/deploy_docusaurus + + + - name: Notify Slack -- deploy failed + if: always() && ( github.event_name == 'push' || github.event_name == 'workflow_dispatch' ) && job.status != 'success' + uses: abinoda/slack-action@master + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN_AIRBYTE_TEAM }} + with: + # 'C02TYDSUM8F' => '#dev-deploys' + # 'C03BEADRPNY' => '#docs' + args: >- + {\"channel\":\"C02TYDSUM8F\",\"attachments\":[ + {\"color\":\"#ff0000\",\"blocks\":[ + {\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"OSS Docs deploy fails on the latest master :bangbang:\"}}, + {\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"_merged by_: *${{ github.actor }}*\"}}, + {\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"\"}} + ]}]} - - name: Notify Slack channel on failure + - name: Notify Slack -- deploy succeeded + if: always() && ( github.event_name == 'push' || github.event_name == 'workflow_dispatch' ) && job.status == 'success' uses: abinoda/slack-action@master - if: failure() env: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN_AIRBYTE_TEAM }} with: - # 'C032Y32T065' channel => '#docs' + # 'C02TYDSUM8F' => '#dev-deploys' + # 'C03BEADRPNY' => '#docs' args: >- - {\"channel\":\"C03BEADRPNY\", \"blocks\":[ - {\"type\":\"divider\"}, - {\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"OSS Docs build fails on the latest master :bangbang: \n\n\"}}, - {\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"_merged by_: *${{ github.actor }}* \n\"}}, - {\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\" :octavia-shocked: :octavia-shocked: \n\"}}, - {\"type\":\"divider\"}]} + {\"channel\":\"C02TYDSUM8F\",\"attachments\":[ + {\"color\":\"#00ff00\",\"blocks\":[ + {\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"OSS Docs deploy was successful :tada:\"}}, + {\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"_merged by_: *${{ github.actor }}*\"}}, + {\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"\"}} + ]}]} diff --git a/tools/bin/deploy_docusaurus b/tools/bin/deploy_docusaurus index 07eab74a2609..ab435502e513 100755 --- a/tools/bin/deploy_docusaurus +++ b/tools/bin/deploy_docusaurus @@ -95,8 +95,19 @@ if test "$(tty)" == "not a tty"; then else yarn run deploy fi +YARN_DEPLOY_EXIT_STATUS=$? +# At this moment we have a bunch of changed files in Git (local) working +# directory. What is left -- is pushing changes back to Git repo to +# make changes available to everyone. However, this same script is +# used to validate "deployability" of Github PRs. And while we are in +# "check PR mode" -- we do not want to push changes back to Git repo: +if [ "${SKIP_DEPLOY}" = "yes" ]; then + echo -e "$blue_text""Check mode is ON: skipipping Git push to git repo!\n\n""$default_text" + exit $YARN_DEPLOY_EXIT_STATUS +fi + # Git makes more sense from / cd ..