diff --git a/.github/workflows/ansys_lab.yml b/.github/workflows/ansys_lab.yml index c56a2af496..1d66c6383f 100644 --- a/.github/workflows/ansys_lab.yml +++ b/.github/workflows/ansys_lab.yml @@ -5,18 +5,16 @@ on: workflow_call: inputs: version: - description: "Release tag as 'tags/XX' (defaults to latest)" + description: "Release version as 'X.Y.Z'" type: string - required: false - default: latest + required: true # Can be called manually workflow_dispatch: inputs: version: - description: "Release tag as 'tags/XX' (defaults to latest)" + description: "Release version as 'X.Y.Z'" type: string - required: false - default: latest + required: true env: DESTINATION_BRANCH_NAME: ansys_lab_examples @@ -28,25 +26,51 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: env.DESTINATION_BRANCH_NAME + 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/fetch-gh-release-asset@1.1.0 with: file: HTML-doc-ansys-dpf-core.zip token: ${{ secrets.GITHUB_TOKEN }} - version: ${{ inputs.version }} + 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-core.zip", 'r') as z: [z.extract(file, "./") for file in z.namelist() if file.endswith(".ipynb")] os.remove("HTML-doc-ansys-dpf-core.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: "Show changes" + - name: "Push changes" shell: bash run: | - git status \ No newline at end of file + 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-core.git --follow-tags diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml index c2de4618b1..3203afa2de 100644 --- a/.github/workflows/releaser.yml +++ b/.github/workflows/releaser.yml @@ -106,3 +106,9 @@ jobs: api-key: ${{ env.MEILISEARCH_API_KEY }} doc-artifact-name: HTML-doc-ansys-dpf-core.zip decompress-artifact: true + + update_ansys_lab_examples: + uses: ./.github/workflows/ansys_lab.yml + with: + version: ${{ github.event.inputs.release_tag || 'latest' }} + secrets: inherit