|
| 1 | +name: Ansys Lab |
| 2 | + |
| 3 | +on: |
| 4 | +# Can be called by the CI |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + version: |
| 8 | + description: "Release version as 'X.Y.Z'" |
| 9 | + type: string |
| 10 | + required: true |
| 11 | +# Can be called manually |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + version: |
| 15 | + description: "Release version as 'X.Y.Z'" |
| 16 | + type: string |
| 17 | + required: true |
| 18 | + |
| 19 | +env: |
| 20 | + DESTINATION_BRANCH_NAME: ansys_lab_examples |
| 21 | + |
| 22 | +jobs: |
| 23 | + deploy_examples: |
| 24 | + name: "Deploy examples for Ansys Lab" |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + ref: ${{ env.DESTINATION_BRANCH_NAME }} |
| 30 | + |
| 31 | + - name: "Clean-up working directory" |
| 32 | + shell: python |
| 33 | + run: | |
| 34 | + import glob |
| 35 | + import os |
| 36 | + |
| 37 | + for example in glob.glob('**/*.ipynb', recursive=True): |
| 38 | + os.remove(example) |
| 39 | + print(f"Deleted {example}") |
| 40 | +
|
| 41 | + - name: "Download Release Asset - HTML" |
| 42 | + |
| 43 | + with: |
| 44 | + file: HTML-doc-ansys-dpf-post.zip |
| 45 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + version: tags/v${{ inputs.version }} |
| 47 | + |
| 48 | + - name: "Extract ipynb examples" |
| 49 | + shell: python |
| 50 | + run: | |
| 51 | + import glob |
| 52 | + import os |
| 53 | + import shutil |
| 54 | + import zipfile |
| 55 | + with zipfile.ZipFile("HTML-doc-ansys-dpf-post.zip", 'r') as z: |
| 56 | + [z.extract(file, "./") for file in z.namelist() if file.endswith(".ipynb")] |
| 57 | + os.remove("HTML-doc-ansys-dpf-post.zip") |
| 58 | + |
| 59 | + if not "examples" in os.listdir(os.getcwd()): |
| 60 | + os.mkdir(os.path.join(os.getcwd(), "examples")) |
| 61 | + print(os.listdir(os.getcwd())) |
| 62 | + for folder in os.listdir(os.path.join(os.getcwd(), "_downloads")): |
| 63 | + print(os.listdir(os.path.join(os.path.join(os.getcwd(), "_downloads"), folder))) |
| 64 | + for example in glob.glob('**/*.ipynb', recursive=True): |
| 65 | + print(f"Moving {example}") |
| 66 | + shutil.move(example, os.path.join(os.getcwd(), "examples")) |
| 67 | + print(os.listdir(os.path.join(os.getcwd(), "examples"))) |
| 68 | +
|
| 69 | + - name: "Push changes" |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + git config --global user.name "rlagha" |
| 73 | + git add . |
| 74 | + git status |
| 75 | + git commit -a -m ${{ inputs.version }} |
| 76 | + git push https://${{ secrets.DPF_PIPELINE }}@github.com/ansys/pydpf-post.git --follow-tags |
0 commit comments