ci: sync docs with libretime/website repository
This commit is contained in:
parent
583169e079
commit
b461394801
|
@ -2,19 +2,22 @@ name: Docs
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main, 3.0.x]
|
||||||
paths:
|
paths:
|
||||||
- .github/vale/**
|
- .github/vale/**
|
||||||
- .github/workflows/docs.yml
|
- .github/workflows/docs.yml
|
||||||
- docs/**
|
- docs/**
|
||||||
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main, 3.0.x]
|
||||||
paths:
|
paths:
|
||||||
- .github/vale/**
|
- .github/vale/**
|
||||||
- .github/workflows/docs.yml
|
- .github/workflows/docs.yml
|
||||||
- docs/**
|
- docs/**
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
name: Lint
|
name: Lint
|
||||||
|
@ -51,3 +54,24 @@ jobs:
|
||||||
vale sync
|
vale sync
|
||||||
vale --output line docs || true
|
vale --output line docs || true
|
||||||
vale --output line --minAlertLevel=error docs/releases
|
vale --output line --minAlertLevel=error docs/releases
|
||||||
|
|
||||||
|
sync:
|
||||||
|
name: Sync
|
||||||
|
if: >
|
||||||
|
github.repository_owner == 'libretime' &&
|
||||||
|
github.event_name == 'push'
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: libretime/website
|
||||||
|
path: website
|
||||||
|
ssh-key: "${{ secrets.WEBSITE_DEPLOY_KEY }}"
|
||||||
|
|
||||||
|
- name: Sync docs changes
|
||||||
|
run: tools/ci-sync-docs.sh ${{ github.event.before }}..${{ github.sha }}
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Sync the docs folder with the libretime/website repository.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
error() {
|
||||||
|
echo >&2 "error: $*"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
command -v git > /dev/null || error "git command not found!"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat >&2 <<- EOF
|
||||||
|
Usage : $0 <commit_range>
|
||||||
|
|
||||||
|
Positional arguments:
|
||||||
|
commit_range Commit range to scan for changes within the docs folder.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $# -lt 1 ]]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
commit_range="$1"
|
||||||
|
|
||||||
|
[[ -n "$GITHUB_REF_NAME" ]] || error "GITHUB_REF_NAME variable is not set!"
|
||||||
|
[[ -n "$GITHUB_REPOSITORY" ]] || error "GITHUB_REPOSITORY variable is not set!"
|
||||||
|
|
||||||
|
git config --global user.name "libretime-bot"
|
||||||
|
git config --global user.email "libretime-bot@users.noreply.github.com"
|
||||||
|
|
||||||
|
if [[ "$GITHUB_REF_NAME" == "main" ]]; then
|
||||||
|
dest="docs"
|
||||||
|
else
|
||||||
|
dest="versioned_docs/version-$GITHUB_REF_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for commit in $(git rev-list --reverse --no-merges "$commit_range" -- docs); do
|
||||||
|
rm -fR "website/$dest"
|
||||||
|
cp -r "docs" "website/$dest"
|
||||||
|
|
||||||
|
git show \
|
||||||
|
--quiet \
|
||||||
|
--format="%B%n${GITHUB_REPOSITORY}@%H" \
|
||||||
|
"$commit" \
|
||||||
|
> commit-message
|
||||||
|
|
||||||
|
pushd website
|
||||||
|
git add "$dest"
|
||||||
|
git diff-index --quiet HEAD -- || git commit --file=../commit-message
|
||||||
|
popd
|
||||||
|
rm commit-message
|
||||||
|
done
|
||||||
|
|
||||||
|
pushd website
|
||||||
|
git push
|
||||||
|
popd
|
Loading…
Reference in New Issue