Skip to content

Content Updater

Content Updater #404

Workflow file for this run

name: Content Updater
on:
workflow_dispatch:
schedule:
# every day, 4 AM PST
- cron: "0 12 * * *"
jobs:
check-for-update:
name: Check for Update
runs-on: ubuntu-22.04
outputs:
version-sf-pypi: ${{ steps.set-version.outputs.version }}
steps:
- name: Checkout static-frame-www
uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
- name: Collect versions, fail if no updated needed
id: set-version
run: |
export VERSION_SF_PYPI=$(curl -s https://pypi.org/pypi/static-frame/json | jq -r '.info.version')
echo "version pypi: $VERSION_SF_PYPI"
echo "version=v${VERSION_SF_PYPI}" >> $GITHUB_OUTPUT
export VERSION_SF_CURRENT=$(jq -r '.version' site-static-frame/src/sf-api/metadata.json)
echo "version current: $VERSION_SF_CURRENT"
# if [ "$VERSION_SF_PYPI" == "$VERSION_SF_CURRENT" ]; then
# echo "update needed: no"
# exit 1
# else
# echo "update needed: yes"
# fi
update-rtd:
name: Update Read the Docs
needs: [check-for-update]
runs-on: ubuntu-22.04
steps:
- name: Trigger RTD Latest Builds
run: |
curl -X POST \
-H "Authorization: Token ${{ secrets.RTD_TOKEN }}" \
-H "Content-Type: application/json" \
"https://readthedocs.org/api/v3/projects/static-frame/versions/latest/builds/"
update-site-content:
name: Update Site Content
needs: [check-for-update]
runs-on: ubuntu-22.04
steps:
- name: Checkout static-frame-www
uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
fetch-depth: 1
- name: Checkout static-frame
uses: actions/checkout@v3
with:
repository: 'static-frame/static-frame'
path: 'static-frame' # this is inside the static-frame-www repo
ref: ${{ needs.check-for-update.outputs.version-sf-pypi }}
- uses: actions/setup-python@v4
with:
python-version: '3.13'
- name: Build SF Docs
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev-3_13.txt
export PYTHONPATH="${PYTHONPATH}:."
python3 doc/build_doc.py
working-directory: static-frame
- name: Convert HTML Docs to MD
run: |
pip install -r training/requirements.txt
export PYTHONPATH="${PYTHONPATH}:."
python3 training/convert.py -i ../static-frame/doc/build/html -o training/doc
- name: Build JSON files
run: |
pip install -r requirements-dev-3_13.txt
export PYTHONPATH="${PYTHONPATH}:."
python3 doc/build_json.py --write --output ../site-static-frame/src/sf-api
working-directory: static-frame
- name: Remove static-frame
run: rm -rf static-frame
- name: Extract New Version
run: |
export VERSION_SF_SOURCED=$(jq -r '.version' site-static-frame/src/sf-api/metadata.json)
echo "VERSION_SF_SOURCED=$VERSION_SF_SOURCED" >> $GITHUB_ENV
export NAME_BRANCH="content-update-${VERSION_SF_SOURCED}-${GITHUB_RUN_ID}"
echo "NAME_BRANCH=$NAME_BRANCH" >> $GITHUB_ENV
- name: Commit to Git
run: |
git diff --stat
git config user.email "bot@staticframe.dev"
git config user.name "Content Update Bot"
git checkout -b "${NAME_BRANCH}"
git commit -m "${NAME_BRANCH}" -a
git push origin ${NAME_BRANCH}
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_DATA=$(jq -n \
--arg title "Content Update ${VERSION_SF_SOURCED} (${GITHUB_RUN_ID})" \
--arg body "--" \
--arg head "${NAME_BRANCH}" \
--arg base "main" \
--argjson assignees '["flexatone"]' \
'{"title": $title, "body": $body, "head": $head, "base": $base}')
curl --location --request POST "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls" \
--header "Authorization: token ${GITHUB_TOKEN}" \
--header "Content-Type: application/json" \
--data "$PR_DATA"