Skip to content

Commit

Permalink
Add ansys_lab.yml (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
PProfizi authored Nov 21, 2023
1 parent 942fab1 commit c333669
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/ansys_lab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Ansys Lab

on:
# Can be called by the CI
workflow_call:
inputs:
version:
description: "Release version as 'X.Y.Z'"
type: string
required: true
# Can be called manually
workflow_dispatch:
inputs:
version:
description: "Release version as 'X.Y.Z'"
type: string
required: true

env:
DESTINATION_BRANCH_NAME: ansys_lab_examples

jobs:
deploy_examples:
name: "Deploy examples for Ansys Lab"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.DESTINATION_BRANCH_NAME }}

- name: "Clean-up working directory"
shell: python
run: |
import glob
import os
for example in glob.glob('**/*.ipynb', recursive=True):
os.remove(example)
print(f"Deleted {example}")
- name: "Download Release Asset - HTML"
uses: dsaltares/[email protected]
with:
file: HTML-doc-ansys-dpf-post.zip
token: ${{ secrets.GITHUB_TOKEN }}
version: tags/v${{ inputs.version }}

- name: "Extract ipynb examples"
shell: python
run: |
import glob
import os
import shutil
import zipfile
with zipfile.ZipFile("HTML-doc-ansys-dpf-post.zip", 'r') as z:
[z.extract(file, "./") for file in z.namelist() if file.endswith(".ipynb")]
os.remove("HTML-doc-ansys-dpf-post.zip")
if not "examples" in os.listdir(os.getcwd()):
os.mkdir(os.path.join(os.getcwd(), "examples"))
print(os.listdir(os.getcwd()))
for folder in os.listdir(os.path.join(os.getcwd(), "_downloads")):
print(os.listdir(os.path.join(os.path.join(os.getcwd(), "_downloads"), folder)))
for example in glob.glob('**/*.ipynb', recursive=True):
print(f"Moving {example}")
shutil.move(example, os.path.join(os.getcwd(), "examples"))
print(os.listdir(os.path.join(os.getcwd(), "examples")))
- name: "Push changes"
shell: bash
run: |
git config --global user.name "rlagha"
git add .
git status
git commit -a -m ${{ inputs.version }}
git push https://${{ secrets.DPF_PIPELINE }}@github.com/ansys/pydpf-post.git --follow-tags
6 changes: 6 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
doc-artifact-name: HTML-doc-ansys-dpf-post.zip
decompress-artifact: true

update_ansys_lab_examples:
uses: ./.github/workflows/ansys_lab.yml
with:
version: latest
secrets: inherit

0 comments on commit c333669

Please sign in to comment.