Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add data object inspection documentation example (#258) #59

Add data object inspection documentation example (#258)

Add data object inspection documentation example (#258) #59

name: Docs Artifacts Upload
on:
pull_request:
push:
branches:
- master
release:
types: [published]
env:
ARTIFACT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
jobs:
docs-artifacts:
runs-on: ubuntu-latest
permissions:
contents: read
statuses: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.ARTIFACT_SHA }}
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v4
with:
activate-environment: numcosmo_developer
environment-file: environment.yml
auto-activate-base: false
auto-update-conda: true
- name: Install LaTeX
run: |
sudo apt-get update
sudo apt-get install -y \
texlive-latex-base \
texlive-latex-extra \
texlive-fonts-recommended \
cm-super \
dvipng
- name: Build documentation
shell: bash -l {0}
run: |
meson setup BDocs -Ddocumentation=true
meson compile -C BDocs
- name: Upload documentation site
uses: actions/upload-artifact@v4
with:
name: numcosmo-site-${{ env.ARTIFACT_SHA }}
path: BDocs/docs/numcosmo-site
if-no-files-found: error
- name: Trigger RTD build
env:
RTD_TOKEN: ${{ secrets.RTD_TOKEN }}
run: |
set -e
echo "===== RTD Trigger ====="
date
echo ""
if [ -z "${RTD_TOKEN}" ]; then
echo "SKIP: RTD_TOKEN not set; skipping Read the Docs build trigger."
echo "BUILD_URL=" >> "${GITHUB_ENV}"
exit 0
fi
if [ "${{ github.event_name }}" = "pull_request" ]; then
VERSION="${{ github.event.pull_request.number }}"
elif [ "${{ github.event_name }}" = "release" ]; then
VERSION="stable"
elif [ "${{ github.ref_name }}" = "master" ]; then
VERSION="latest"
else
VERSION="${{ github.ref_name }}"
fi
echo "GitHub event: ${{ github.event_name }}"
echo "GitHub ref: ${{ github.ref }}"
echo "RTD version: ${VERSION}"
echo ""
API_URL="https://app.readthedocs.org/api/v3/projects/numcosmo/versions/${VERSION}/builds/"
echo "API URL:"
echo "${API_URL}"
echo ""
HTTP_CODE=$(curl -L -s -o /tmp/rtd_response.json -w "%{http_code}" -X POST -H "Authorization: Token ${RTD_TOKEN}" -H "Content-Type: application/json" "${API_URL}")
echo "HTTP status: ${HTTP_CODE}"
echo ""
echo "===== RTD Response ====="
cat /tmp/rtd_response.json || true
echo ""
echo "========================"
echo ""
if [ "${HTTP_CODE}" -ge 200 ] && [ "${HTTP_CODE}" -lt 300 ]; then
BUILD_URL=$(python3 -c "import json; print(json.load(open('/tmp/rtd_response.json'))['build']['urls']['build'])")
echo "RTD build URL:"
echo "${BUILD_URL}"
echo "BUILD_URL=${BUILD_URL}" >> "${GITHUB_ENV}"
echo "SUCCESS"
else
echo "FAILED"
exit 1
fi
- name: Add RTD link to PR
if: github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/${{ github.repository }}/statuses/${{ env.ARTIFACT_SHA }} \
-f state=success \
-f context="Read the Docs" \
-f target_url="${BUILD_URL}" \
-f description="Open RTD build" \
|| echo "Unable to create commit status (likely fork PR); skipping."