Skip to content

Update community_versions.json #191

Update community_versions.json

Update community_versions.json #191

Workflow file for this run

name: Publish docs via GitHub Pages
env:
ACTIONTEST: 3.6.0
# branch name, like master, 2.4
on:
push:
branches: # hard code branch name
- v3.6.0
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1 # Not fetch all commits/branches
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name : prepare
run: pip install -r requirements.txt
- name: Set matrix
id: set-matrix
run: |
import yaml, os, json
with open('./database_edition.yml', 'r') as file:
mkdocs = yaml.safe_load(file)
database_edition = mkdocs.get('database_edition', '')
print(f"database_edition: {database_edition}") # Print the variable for debugging
matrix = []
if database_edition == 'both':
matrix = ['enterprise', 'community']
elif database_edition in ['enterprise', 'community']:
matrix = [database_edition]
matrix_str = json.dumps(matrix) # Convert the list to a JSON-formatted string
with open(os.environ['GITHUB_OUTPUT'], 'a') as file:
file.write(f"matrix={matrix_str}\n")
shell: python
deploy:
needs: prepare
runs-on: ubuntu-latest
strategy:
max-parallel: 1 # in case push conflict
matrix:
database_edition: ${{fromJson(needs.prepare.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1 # fetch all commits/branches
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name : prepare
run: sh ./prepare.sh
# if 'both', set each file 'community' and 'enterprise' separately.
- name: Update database_edition.yml
run: |
import yaml
with open('./database_edition.yml', 'r') as file:
content = yaml.safe_load(file)
content['database_edition'] = f"${{ matrix.database_edition }}"
with open('./database_edition.yml', 'w') as file:
yaml.dump(content, file)
shell: python
- name: Git Config
run: git config user.name whitewum && git config user.email min.wu@vesoft.com
- name: save tmp files
run: |
cp -f *versions.json /tmp/ # f"${{ matrix.database_edition }}"_versions.json
ls /tmp/ -ltr
- name: mike
run: |
python ./scripts/conditional_render.py
python ./scripts/conditional_yml.py
python ./scripts/conditional_pdf.py
git fetch origin gh-pages --depth=1 # fix mike's CI update
mike deploy ${{ env.ACTIONTEST }} -p --rebase
mike set-default ${{ env.ACTIONTEST }} -p --rebase
mike list
- name: show git branch
run: |
git branch
git checkout .
git checkout gh-pages
- name: replace version.json
run: |
import yaml, json
new_content = {"version": "${{ env.ACTIONTEST }}", "title": "${{ env.ACTIONTEST }}", "aliases": []}
# the only place read from /tmp/
filename = "/tmp/" + f"${{ matrix.database_edition }}" + "_versions.json"
with open(filename, 'r') as infile:
json_data = json.load(infile)
found = False
for item in json_data:
if item['version'] == new_content['version']: # in case duplicate master branch
found = True
break
if not found:
json_data.append(new_content)
json_data = sorted(json_data, key=lambda x: x['version'], reverse=True)
with open('./versions.json', 'w') as outfile:
json.dump(json_data, outfile, indent=2)
shell: python
- name: Compress
run: |
if [ "${{ matrix.database_edition }}" = "enterprise" ]; then
tar -vczf ent-docs.tar.gz ${{ env.ACTIONTEST }} versions.json *.html
else
tar -vczf nebula-docs.tar.gz ${{ env.ACTIONTEST }} versions.json *.html
fi
- name: Set source file
id: set-source-file
run: |
if [ "${{ matrix.database_edition }}" = "enterprise" ]; then
echo "source_file=ent-docs.tar.gz" >> $GITHUB_OUTPUT
else
echo "source_file=nebula-docs.tar.gz" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Transfer
# uses: garygrossgarten/github-action-scp@release
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER_NAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
source: ${{ steps.set-source-file.outputs.source_file }}
target: /usr/web
- name: UnCompress
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER_NAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
if [ "${{ matrix.database_edition }}" = "enterprise" ]; then
mkdir -p /usr/web/ent-docs/
tar -xzf /usr/web/ent-docs.tar.gz -C /usr/web/ent-docs/
mkdir -p /usr/web/ent-docs/site/pdf/
#cp -f /usr/web/ent-docs/${{ env.ACTIONTEST }}/pdf/yueshu-cn.pdf /usr/web/ent-docs/site/pdf/NebulaGraph-book.pdf
else
mkdir -p /usr/web/nebula-docs/
tar -xzf /usr/web/nebula-docs.tar.gz -C /usr/web/nebula-docs/
mkdir -p /usr/web/nebula-docs/site/pdf/
#cp -f /usr/web/nebula-docs/${{ env.ACTIONTEST }}/pdf/NebulaGraph-CN.pdf /usr/web/nebula-docs/site/pdf/NebulaGraph-book.pdf
fi
- name: Set OSS parameters
id: set-oss-params
run: |
if [ "${{ matrix.database_edition }}" = "enterprise" ]; then
echo "bucket=yueshu-graph" >> $GITHUB_OUTPUT
echo "asset_path=${{ env.ACTIONTEST }}/pdf/yueshu-cn.pdf" >> $GITHUB_OUTPUT
echo "target_path=general/yueshu-doc/${{ env.ACTIONTEST }}" >> $GITHUB_OUTPUT
else
echo "bucket=docs-cn" >> $GITHUB_OUTPUT
echo "asset_path=${{ env.ACTIONTEST }}/pdf/NebulaGraph-CN.pdf" >> $GITHUB_OUTPUT
echo "target_path=pdf/${{ env.ACTIONTEST }}" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Upload to OSS
uses: vesoft-inc/upload-oss@master
with:
key-id: ${{ secrets.OSS_ID }}
key-secret: ${{ secrets.OSS_SECRET }}
endpoint: ${{ secrets.OSS_ENDPOINT }}
bucket: ${{ steps.set-oss-params.outputs.bucket }}
asset-path: ${{ steps.set-oss-params.outputs.asset_path }}
target-path: ${{ steps.set-oss-params.outputs.target_path }}