Skip to content

Commit

Permalink
Merge pull request #38 from scylladb/revert-37-revert-34-publish-manu…
Browse files Browse the repository at this point in the history
…al-scripts

docs: add scripts publish docs.scylladb.com/manual
  • Loading branch information
annastuchlik authored Jan 15, 2025
2 parents 10bf708 + 4886580 commit 5e21653
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 21 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/docs-manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Docs / Publish docs.scylladb.com/manual"

env:
FLAG: 'manual'

on:
schedule:
# Run daily at 00:00 UTC
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false
fetch-depth: 0
submodules: true

- name: Fetch submodules latest version
run: |
git submodule sync
git submodule update --init --remote
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Set up env
run: make -C submodules/scylladb/docs FLAG="${{ env.FLAG }}" setupenv

- name: Build docs
run: make -C submodules/scylladb/docs FLAG="${{ env.FLAG }}" multiversion

- name: Build redirects
run: make -C submodules/scylladb/docs FLAG="${{ env.FLAG }}" redirects

- name: Deploy docs to GitHub Pages
run: ./scripts/deploy_manual.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 2 additions & 3 deletions .github/workflows/docs-pages.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: "Docs / Publish"
name: "Docs / Publish docs.scylladb.com"
# For more information,
# see https://sphinx-theme.scylladb.com/stable/deployment/production.html#available-workflows

on:
push:
branches:
- main
- 'branch-**'
paths:
- "docs/**"
workflow_dispatch:
Expand All @@ -32,6 +31,6 @@ jobs:
- name: Build redirects
run: make -C docs redirects
- name: Deploy docs to GitHub Pages
run: ./docs/_utils/deploy.sh
run: ./scripts/deploy_pages.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "submodules/scylladb"]
path = submodules/scylladb
url = https://github.com/scylladb/scylladb.git
18 changes: 0 additions & 18 deletions docs/_utils/deploy.sh

This file was deleted.

36 changes: 36 additions & 0 deletions scripts/deploy_manual.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

# Variables
REPO_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
GH_PAGES_DIR="gh-pages"

echo "Preparing docs dir..."
mkdir -p $GH_PAGES_DIR
cp -r ./submodules/scylladb/docs/_build/dirhtml/. $GH_PAGES_DIR

if git ls-remote --heads "$REPO_URL" gh-pages; then
echo "Cloning existing gh-pages branch..."
git clone --branch gh-pages --single-branch "$REPO_URL" "${GH_PAGES_DIR}-existing"
cd "${GH_PAGES_DIR}-existing"

echo "Cleaning up existing content..."
rm -rf manual

echo "Copying new documentation..."
mkdir -p manual
cp -a ../$GH_PAGES_DIR/. manual/

echo "Configuring Git..."
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"

echo "Committing and pushing changes..."
git add .
git commit -m "Update docs" || true
git push origin gh-pages --force

else
echo "Error: The gh-pages branch does not exist in the repository."
echo "Please create a gh-pages branch in your repository and re-run the script."
exit 1
fi
34 changes: 34 additions & 0 deletions scripts/deploy_pages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# Variables
REPO_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
GH_PAGES_DIR="gh-pages"

echo "Preparing docs dir..."
mkdir -p $GH_PAGES_DIR
cp -r ./docs/_build/dirhtml/. $GH_PAGES_DIR

if git ls-remote --heads "$REPO_URL" gh-pages; then
echo "Cloning existing gh-pages branch..."
git clone --branch gh-pages --single-branch "$REPO_URL" "${GH_PAGES_DIR}-existing"
cd "${GH_PAGES_DIR}-existing"

echo "Cleaning up existing content..."
find . -mindepth 1 -not -path './.git*' -not -path './manual*' -exec rm -rf {} +

echo "Copying new documentation..."
cp -a ../$GH_PAGES_DIR/. .

echo "Configuring Git..."
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"

echo "Committing and pushing changes..."
git add .
git commit -m "Update docs" || true
git push origin gh-pages --force
else
echo "Error: The gh-pages branch does not exist in the repository."
echo "Please create a gh-pages branch in your repository and re-run the script."
exit 1
fi
1 change: 1 addition & 0 deletions submodules/scylladb
Submodule scylladb added at 4260f3

0 comments on commit 5e21653

Please sign in to comment.