From 441af4d09f489fd40cbab577cfac2de34d456873 Mon Sep 17 00:00:00 2001 From: Joseph Glaser Date: Wed, 16 Oct 2024 19:55:06 +0000 Subject: [PATCH] Fixing archive name and testing archive commenting. --- .github/workflows/commenting_artifacts.yml | 50 ++++++++++++++++++++++ .github/workflows/test_notebook.yml | 7 ++- 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/commenting_artifacts.yml diff --git a/.github/workflows/commenting_artifacts.yml b/.github/workflows/commenting_artifacts.yml new file mode 100644 index 0000000..bd7bc20 --- /dev/null +++ b/.github/workflows/commenting_artifacts.yml @@ -0,0 +1,50 @@ +name: Bind Reports to Pull-Request + +# Triggered by the name of the previos +on: + workflow_run: + workflows: ["Notebook Pipeline (Ubuntu)"] + types: [completed] + +# Enable the option to post a comment +permissions: + pull-requests: write + +jobs: + build: + runs-on: ubuntu-latest + # Check that the previos workflow succeeded + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Get Artifacts Link + env: + WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }} + GH_TOKEN: ${{ github.token }} + run: | + PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ") + SUITE_ID=$(jq -r '.check_suite_id' <<< "$WORKFLOW_RUN_EVENT_OBJ") + # Sample for a single artifact, can be improved for a multiple artifacts + ARTIFACT_ID=$(gh api "/repos/${{ github.repository }}/actions/artifacts" \ + --jq ".artifacts.[] | + select(.workflow_run.id==${PREVIOUS_JOB_ID}) | + .id") + echo "ARTIFACT_URL=https://github.com/${{ github.repository }}/suites/${SUITE_ID}/artifacts/${ARTIFACT_ID}" >> $GITHUB_ENV + PR_NUMBER=$(jq -r '.pull_requests[0].number' <<< "$WORKFLOW_RUN_EVENT_OBJ") + echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV + + - uses: actions/github-script@v6 + env: + PR_NUMBER: ${{ env.PR_NUMBER }} + PR_NOTES: | + Build artifacts: + | Name | Link | + |------|------| + | NB/WB Pipeline | [Archived ZIP](${{ env.ARTIFACT_URL }}) | + with: + script: | + github.rest.issues.createComment({ + issue_number: process.env.PR_NUMBER, + owner: context.repo.owner, + repo: context.repo.repo, + body: process.env.PR_NOTES + }) \ No newline at end of file diff --git a/.github/workflows/test_notebook.yml b/.github/workflows/test_notebook.yml index a7b5f54..cd1c5f8 100644 --- a/.github/workflows/test_notebook.yml +++ b/.github/workflows/test_notebook.yml @@ -64,7 +64,10 @@ jobs: - name: Archive Notebook Output Files uses: actions/upload-artifact@v4 with: - name: TestNB-OutputFiles + name: TestNB-OutputFiles_${{ matrix.python-version }}_${{ matrix.os }}_${{ steps.date.outputs.date }} path: | - nb_outputs + nb_outputs/*/*.pdf + nb_outputs/*/*.tim + nb_outputs/*/*.par + compression-level: 6