Skip to content

Commit

Permalink
TO-REMOVE
Browse files Browse the repository at this point in the history
  • Loading branch information
thomass-dev committed Jan 14, 2025
1 parent fcba013 commit 17ed382
Showing 1 changed file with 132 additions and 131 deletions.
263 changes: 132 additions & 131 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ name: sphinx

on:
pull_request:
paths:
- '.github/actions/sphinx/**'
- '.github/workflows/sphinx.yml'
- 'examples/**'
- 'sphinx/**'
- 'skore/**'
push:
branches:
- main
paths:
- '.github/actions/sphinx/**'
- '.github/workflows/sphinx.yml'
- 'examples/**'
- 'sphinx/**'
- 'skore/**'
release:
types: [released]
# paths:
# - '.github/actions/sphinx/**'
# - '.github/workflows/sphinx.yml'
# - 'examples/**'
# - 'sphinx/**'
# - 'skore/**'
# push:
# branches:
# - main
# paths:
# - '.github/actions/sphinx/**'
# - '.github/workflows/sphinx.yml'
# - 'examples/**'
# - 'sphinx/**'
# - 'skore/**'
# release:
# types: [released]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -95,47 +95,48 @@ jobs:
echo "SPHINX_RELEASE=${GITHUB_REF_NAME}" >> "${GITHUB_OUTPUT}"
fi
sphinx-build:
runs-on: ubuntu-latest
needs: sphinx-version
steps:
- uses: actions/checkout@v4
with:
lfs: 'true'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- uses: ./.github/actions/sphinx/build
with:
SPHINX_VERSION: ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}
SPHINX_RELEASE: ${{ needs.sphinx-version.outputs.SPHINX_RELEASE }}
- uses: actions/upload-artifact@v4
with:
name: sphinx-html-artifact
path: sphinx/build/html/
# sphinx-build:
# runs-on: ubuntu-latest
# needs: sphinx-version
# steps:
# - uses: actions/checkout@v4
# with:
# lfs: 'true'
# - uses: actions/setup-python@v5
# with:
# python-version: '3.12'
# cache: 'pip'
# - uses: ./.github/actions/sphinx/build
# with:
# SPHINX_VERSION: ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}
# SPHINX_RELEASE: ${{ needs.sphinx-version.outputs.SPHINX_RELEASE }}
# - uses: actions/upload-artifact@v4
# with:
# name: sphinx-html-artifact
# path: sphinx/build/html/

sphinx-deploy-html:
if: ${{ (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
# if: ${{ (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
runs-on: ubuntu-latest
needs: [sphinx-version, sphinx-build]
# needs: [sphinx-version, sphinx-build]
needs: [sphinx-version]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download HTML artifacts
uses: actions/download-artifact@v4
with:
name: sphinx-html-artifact
path: html/

- name: Deploy HTML artifacts
uses: ./.github/actions/sphinx/deploy
with:
CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOCS }}
BUCKET: ${{ vars.DOCUMENTATION_BUCKET }}
SOURCE: html/
DESTINATION: ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}/
# - name: Checkout code
# uses: actions/checkout@v4

# - name: Download HTML artifacts
# uses: actions/download-artifact@v4
# with:
# name: sphinx-html-artifact
# path: html/

# - name: Deploy HTML artifacts
# uses: ./.github/actions/sphinx/deploy
# with:
# CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOCS }}
# BUCKET: ${{ vars.DOCUMENTATION_BUCKET }}
# SOURCE: html/
# DESTINATION: ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}/

- name: Purge CDN cache
shell: bash
Expand All @@ -151,80 +152,80 @@ jobs:
PIPELINE_ID: ${{ vars.DOCUMENTATION_EDGE_SERVICES_PIPELINE_ID }}
ASSET: ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}/

sphinx-deploy-root-files:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
needs: [sphinx-version, sphinx-build, sphinx-deploy-html]
steps:
- uses: actions/checkout@v4
- shell: python
run: |
import os
import requests
import operator
import json
url = os.environ["URL"]
version = os.environ["SPHINX_VERSION"]
release = os.environ["SPHINX_RELEASE"]
# Retrieve history
response = requests.get(f"{url}/versions.json")
response.raise_for_status()
history = {version["name"]: version["version"] for version in response.json()}
# Add new version to history
history[version] = release
# Sort history, and always keep "dev" at the beginning
history = sorted(
history.items(),
key=lambda item: float(item[0]) if item[0] != "dev" else float('inf'),
reverse=True
)
# Rewrite the history with "dev" and the 10 latest versions
new = [
{
"name": version,
"version": release,
"url": f"{url}/{version}/",
"preferred": i == 1,
}
for i, (version, release) in enumerate(history[:11])
]
os.mkdir("artifacts")
with open("artifacts/versions.json", "w", encoding="utf-8") as file:
json.dump(new, file, ensure_ascii=False, indent=4)
with open("artifacts/index.html", "w", encoding="utf-8") as file:
file.write(
f"""
<head>
<meta http-equiv=\"refresh\" content=\"0; url={new[1]["url"]}\"/>
</head>
"""
)
env:
URL: ${{ vars.DOCUMENTATION_URL }}
SPHINX_VERSION: ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}
SPHINX_RELEASE: ${{ needs.sphinx-version.outputs.SPHINX_RELEASE }}
- uses: ./.github/actions/sphinx/deploy
with:
CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOCS }}
BUCKET: ${{ vars.DOCUMENTATION_BUCKET }}
ACTION: copy
SOURCE: artifacts/
DESTINATION:

sphinx-clean-artifacts:
runs-on: ubuntu-latest
if: ${{ always() && (github.event_name != 'pull_request') }}
needs: [sphinx-version, sphinx-build, sphinx-deploy-html, sphinx-deploy-root-files]
steps:
- uses: geekyeggo/delete-artifact@v5
with:
name: sphinx-html-artifact
# sphinx-deploy-root-files:
# if: ${{ github.event_name == 'release' }}
# runs-on: ubuntu-latest
# needs: [sphinx-version, sphinx-build, sphinx-deploy-html]
# steps:
# - uses: actions/checkout@v4
# - shell: python
# run: |
# import os
# import requests
# import operator
# import json

# url = os.environ["URL"]
# version = os.environ["SPHINX_VERSION"]
# release = os.environ["SPHINX_RELEASE"]

# # Retrieve history
# response = requests.get(f"{url}/versions.json")
# response.raise_for_status()

# history = {version["name"]: version["version"] for version in response.json()}

# # Add new version to history
# history[version] = release

# # Sort history, and always keep "dev" at the beginning
# history = sorted(
# history.items(),
# key=lambda item: float(item[0]) if item[0] != "dev" else float('inf'),
# reverse=True
# )

# # Rewrite the history with "dev" and the 10 latest versions
# new = [
# {
# "name": version,
# "version": release,
# "url": f"{url}/{version}/",
# "preferred": i == 1,
# }
# for i, (version, release) in enumerate(history[:11])
# ]

# os.mkdir("artifacts")

# with open("artifacts/versions.json", "w", encoding="utf-8") as file:
# json.dump(new, file, ensure_ascii=False, indent=4)

# with open("artifacts/index.html", "w", encoding="utf-8") as file:
# file.write(
# f"""
# <head>
# <meta http-equiv=\"refresh\" content=\"0; url={new[1]["url"]}\"/>
# </head>
# """
# )
# env:
# URL: ${{ vars.DOCUMENTATION_URL }}
# SPHINX_VERSION: ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}
# SPHINX_RELEASE: ${{ needs.sphinx-version.outputs.SPHINX_RELEASE }}
# - uses: ./.github/actions/sphinx/deploy
# with:
# CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOCS }}
# BUCKET: ${{ vars.DOCUMENTATION_BUCKET }}
# ACTION: copy
# SOURCE: artifacts/
# DESTINATION:

# sphinx-clean-artifacts:
# runs-on: ubuntu-latest
# if: ${{ always() && (github.event_name != 'pull_request') }}
# needs: [sphinx-version, sphinx-build, sphinx-deploy-html, sphinx-deploy-root-files]
# steps:
# - uses: geekyeggo/delete-artifact@v5
# with:
# name: sphinx-html-artifact

0 comments on commit 17ed382

Please sign in to comment.