Skip to content
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

ci: refactor docs pipeline (backport #28852) #28868

Merged
merged 2 commits into from
Nov 18, 2022
Merged
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
85 changes: 55 additions & 30 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,89 @@ on:
- v[0-9]+.[0-9]+

jobs:
docs-build:
check:
outputs:
continue: ${{ steps.check.outputs.need_to_build }}
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get commit range (push)
if: ${{ github.event_name == 'push' }}
run: |
echo "COMMIT_RANGE=$GIHTUB_SHA" >> $GITHUB_ENV

- name: Get commit range (pull_request)
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "COMMIT_RANGE=${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV

- name: Get file status
run: |
set +e
git diff --name-only $COMMIT_RANGE | grep \
-e '.github/workflows/docs.yml' \
-e 'docs/**'
echo "FILE_CHANGED=$?" >> $GITHUB_ENV

- name: Check
id: check
shell: bash
run: |
source ci/env.sh
echo "::set-output name=tag::$CI_TAG"
eval "$(ci/channel-info.sh)"
echo "::set-output name=channel::$CHANNEL"
TAG=$CI_TAG

- name: Get specific changed files
id: changed-files-specific
uses: tj-actions/changed-files@v34
with:
files: |
.github/workflows/docs.yml
docs/**
echo "TAG: $TAG"
echo "CHANNEL: $CHANNEL"
echo "FILE_CHANGED: $FILE_CHANGED"

- name: Pre Build
id: prebuild
run: |
echo "tag: ${{ steps.check.outputs.tag }}"
echo "channel: ${{ steps.check.outputs.channel }}"
echo "any changes: ${{ steps.changed-files-specific.outputs.any_changed }}"
echo "::set-output name=need_to_build::${{
steps.check.outputs.tag != ''
||
(
(steps.check.outputs.channel == 'edge' || steps.check.outputs.channel == 'beta')
&&
steps.changed-files-specific.outputs.any_changed != ''
)
}}"
shell: bash
echo need_to_build="$(
if [ "$TAG" != '' ]
then
echo 1
elif [ $FILE_CHANGED = 0 ] && ( [ "$CHANNEL" = "beta" ] || [ "$CHANNEL" = "edge" ] )
then
echo 1
else
echo 0
fi
)" >> $GITHUB_OUTPUT

build_and_deploy:
needs:
- check
if: ${{ needs.check.outputs.continue == 1 }}
name: build & deploy
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node
if: ${{ steps.prebuild.outputs.need_to_build == 'true' }}
uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16

- name: Build
if: ${{ steps.prebuild.outputs.need_to_build == 'true' }}
working-directory: docs
run: |
npm install
./build.sh
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}

notification:
if: failure()
runs-on: ubuntu-20.04
needs:
- check
- build_and_deploy
steps:
- name: Send Slack notifiaction
if: failure()
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
Expand Down