mirror of https://github.com/artf/grapesjs.git
nocodeframeworkdrag-and-dropsite-buildersite-generatortemplate-builderui-builderweb-builderweb-builder-frameworkwebsite-builderno-codepage-builder
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.2 KiB
63 lines
2.2 KiB
name: Publish GrapesJS Docs
|
|
|
|
on:
|
|
push:
|
|
branches: [dev]
|
|
paths:
|
|
- 'docs/**'
|
|
|
|
jobs:
|
|
publish-docs:
|
|
runs-on: ubuntu-latest
|
|
if: "startsWith(github.event.head_commit.message, 'Release GrapesJS docs:')"
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: ./.github/actions/setup-project
|
|
- name: Setup Git
|
|
run: |
|
|
git config --global user.name 'GrapesJSBot'
|
|
git config --global user.email 'services@grapesjs.com'
|
|
- name: Build and Deploy Docs
|
|
env:
|
|
GRAPESJS_BOT_TOKEN: ${{ secrets.GRAPESJS_BOT_TOKEN }}
|
|
GH_TOKEN: ${{ secrets.GRAPESJS_BOT_TOKEN }}
|
|
working-directory: ./docs
|
|
run: |
|
|
# abort on errors
|
|
set -e
|
|
WEBSITE_REPO='GrapesJS/website'
|
|
DEPLOY_BRANCH="deploy-docs-${GITHUB_SHA}"
|
|
SITE_REPO_DIR="$(mktemp -d)"
|
|
|
|
# fetch the current site and prepare a PR branch with the new docs build
|
|
git clone https://x-access-token:${GRAPESJS_BOT_TOKEN}@github.com/$WEBSITE_REPO.git "$SITE_REPO_DIR"
|
|
cd "$SITE_REPO_DIR"
|
|
git checkout -B "$DEPLOY_BRANCH" origin/main
|
|
rm -rf public/docs
|
|
mkdir -p public/docs
|
|
cp -a /home/runner/work/grapesjs/grapesjs/docs/.vuepress/dist/. ./public/docs
|
|
|
|
# stage all and commit
|
|
git add -A
|
|
if git diff --cached --quiet; then
|
|
echo 'No docs changes to deploy'
|
|
exit 0
|
|
fi
|
|
git commit -m "Deploy GrapesJS docs for ${GITHUB_SHA}"
|
|
|
|
# Push the branch and open/update a PR as direct pushes to main are blocked
|
|
git push --force-with-lease origin "$DEPLOY_BRANCH"
|
|
|
|
EXISTING_PR="$(gh pr list --repo "$WEBSITE_REPO" --head "$DEPLOY_BRANCH" --base main --json number --jq '.[0].number')"
|
|
PR_TITLE="Deploy GrapesJS docs for ${GITHUB_SHA}"
|
|
PR_BODY="Automated docs update from GrapesJS/grapesjs@${GITHUB_SHA}."
|
|
|
|
if [ -n "$EXISTING_PR" ]; then
|
|
gh pr edit "$EXISTING_PR" --repo "$WEBSITE_REPO" --title "$PR_TITLE" --body "$PR_BODY"
|
|
else
|
|
gh pr create --repo "$WEBSITE_REPO" --base main --head "$DEPLOY_BRANCH" --title "$PR_TITLE" --body "$PR_BODY"
|
|
fi
|
|
|
|
cd -
|
|
|