forked from docs/doc-exports
adding fetch artifacts job
This commit is contained in:
@ -343,3 +343,79 @@ jobs:
|
||||
else:
|
||||
print(f"No files changed found in {html_loc}")
|
||||
# EOF
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: doc-exports_var
|
||||
path: doc_exports_var.json
|
||||
|
||||
fetch-doc-artifacts:
|
||||
needs: generate-docs
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DOCS_UPDATE_DATA_FILE: metadata.yaml
|
||||
PROJECT_SRC_DIR: ./
|
||||
TEMPLATE_DIR: ./templates
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.10"
|
||||
|
||||
- name: Install dependencies (if needed)
|
||||
run: pip install pyyaml
|
||||
|
||||
- name: Fetch doc-exports_var
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: doc-exports_var
|
||||
|
||||
- name: Show the file content
|
||||
run: cat output.txt
|
||||
|
||||
- name: Fetch artifacts
|
||||
run: |
|
||||
python3 <<EOF
|
||||
import os
|
||||
import tarfile
|
||||
import shutil
|
||||
|
||||
# Load doc_exports_var from JSON
|
||||
with open('doc_exports_var.json') as f:
|
||||
doc_exports_var = json.load(f)
|
||||
# Setup output artifacts directory
|
||||
project_root = os.getcwd()
|
||||
output_dir = os.path.join(project_root, 'artifact-logs')
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
|
||||
for doc0 in doc_exports_var:
|
||||
for doc1 in doc0['docs']:
|
||||
label = f"{doc0['service_type']}_{doc1['type']}"
|
||||
rst_path = os.path.expanduser(os.path.join(doc0['repository'], doc1['rst_location']))
|
||||
archive_name = f"{label}.tar.gz"
|
||||
archive_path = os.path.join(output_dir, archive_name)
|
||||
|
||||
if os.path.isdir(rst_path):
|
||||
print(f"📦 Archiving {rst_path} -> {archive_path}")
|
||||
with tarfile.open(archive_path, "w:gz") as tar:
|
||||
tar.add(rst_path, arcname=".")
|
||||
|
||||
# Look for optional patches
|
||||
for patch_type in ['diff', 'git']:
|
||||
patch_path = os.getenv(f'FETCH_DOC_PATCH_{patch_type.upper()}')
|
||||
if patch_path and os.path.exists(patch_path):
|
||||
patch_name = f"{label}.{patch_type}.patch"
|
||||
print(f"📄 Copying patch: {patch_path} -> {output_dir}/{patch_name}")
|
||||
shutil.copy(patch_path, os.path.join(output_dir, patch_name))
|
||||
|
||||
EOF
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: doc-artifacts
|
||||
path: artifact-logs/
|
||||
|
||||
Reference in New Issue
Block a user