ci: add a script for vercel to determine if builds are necessary (#61713)
This commit is contained in:
committed by
GitHub
parent
8fb22a6bd0
commit
a2685a39f4
27
.github/workflows/docs-build.yml
vendored
27
.github/workflows/docs-build.yml
vendored
@@ -36,22 +36,45 @@ jobs:
|
||||
- name: Checkout Current Branch
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
- name: Set up pnpm
|
||||
- name: Check For Skip Conditions
|
||||
id: check-skip
|
||||
run: |
|
||||
# temporarily disable -e so we can capture a non-zero exit
|
||||
set +e
|
||||
# Run the script and capture the exit code.
|
||||
./docs/check-docs-git-diff.sh
|
||||
exit_code=$?
|
||||
set -e
|
||||
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
echo "✅ Documentation already up-to-date. No build required."
|
||||
echo skip-build=true | tee -a $GITHUB_OUTPUT
|
||||
else
|
||||
echo "❌ Documentation needs to be built."
|
||||
echo skip-build=false | tee -a $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Set Up pnpm
|
||||
if: steps.check-skip.outputs.skip-build != 'true'
|
||||
# pnpm is used to manage the dependencies of the documentation build.
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10.12.1
|
||||
|
||||
- name: Install uv
|
||||
if: steps.check-skip.outputs.skip-build != 'true'
|
||||
uses: astral-sh/setup-uv@v6
|
||||
|
||||
- name: Install Poe
|
||||
if: steps.check-skip.outputs.skip-build != 'true'
|
||||
run: |
|
||||
# Install Poe so we can run the connector tasks:
|
||||
uv tool install poethepoet
|
||||
|
||||
- name: Build Docs
|
||||
if: steps.check-skip.outputs.skip-build != 'true'
|
||||
run: |
|
||||
poe docs-build
|
||||
|
||||
58
docs/check-docs-git-diff.sh
Executable file
58
docs/check-docs-git-diff.sh
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
|
||||
# This script checks the status of the documentation files in the docs directory.
|
||||
# It should return '1' if a build is needed, and '0' if everything is up to date.
|
||||
#
|
||||
# This script will be called by Vercel here:
|
||||
# - https://vercel.com/airbyte-growth/airbyte-docs/settings/git#ignored-build-step
|
||||
#
|
||||
# This script is intended to be run from the root of the Airbyte repository.
|
||||
#
|
||||
# Usage:
|
||||
# ./docs/check-docs-git-diff.sh # Check for any changes in the branch.
|
||||
# ./docs/check-docs-git-diff.sh --latest-commit-only # Only check the latest commit for changes.
|
||||
|
||||
# parse flags
|
||||
LATEST_COMMIT_ONLY=false
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--latest-commit-only)
|
||||
LATEST_COMMIT_ONLY=true
|
||||
echo "⚙️ Running in '--latest-commit-only' mode."
|
||||
echo "Only the most recent commit will be checked for changes."
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $1" >&2;
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
latest_commit_message=$(git log -n 1 --oneline)
|
||||
echo "⚙️ Checking for a skip directive in the commit message: ('$latest_commit_message')"
|
||||
if echo "$latest_commit_message" | grep -Eq "\[(up-to-date|auto-publish)\]"; then
|
||||
echo "✅ Skipping. Commit marked as [up-to-date]/[auto-publish]. ('$latest_commit_message')"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
REMOTE=origin
|
||||
DEFAULT_BRANCH=master
|
||||
COMPARE_TO_REF="${REMOTE}/${DEFAULT_BRANCH}"
|
||||
if [ "$LATEST_COMMIT_ONLY" == 'true' ]; then
|
||||
# We only want to compare the latest commit against the previous one:
|
||||
COMPARE_TO_REF="HEAD^"
|
||||
fi
|
||||
|
||||
echo "⚙️ Checking for git changes within the docs paths..."
|
||||
if git diff "${COMPARE_TO_REF}"...HEAD --quiet ./docusaurus ./docs .markdownlint.jsonc; then
|
||||
echo "✅ No changes in docs paths. Skipping build."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If we got here, then both of these conditions are true:
|
||||
# 1. There were changes in the docs or current directory, and
|
||||
# 2. The commit didn't have one of the tags [up-to-date] or [auto-publish].
|
||||
echo "❌ Documentation changes detected. Build is requested."
|
||||
exit 1
|
||||
Reference in New Issue
Block a user