Skip to content

Commit 9edb5f8

Browse files
authored
ci: update deploy_pr_doc logic (#2536)
1 parent ff8a3c0 commit 9edb5f8

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

.github/workflows/doc-deploy-pr.yml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ name: doc-deploy-PR
22

33
on:
44
workflow_run:
5-
workflows: [docs]
5+
workflows: [ci]
66
types: [completed]
7+
pull_request:
8+
types: [closed]
79

810
env:
911
DOCUMENTATION_CNAME: 'dpf.docs.pyansys.com'
@@ -20,27 +22,48 @@ jobs:
2022
name: "Deploy PR documentation"
2123
runs-on: ubuntu-latest
2224
if: |
23-
github.event.workflow_run.conclusion == 'success' &&
24-
contains(github.event.workflow_run.pull_requests.*.labels.*.name, 'deploy-pr-doc')
25+
(
26+
github.event_name == 'workflow_run' &&
27+
github.event.workflow_run.conclusion == 'success' &&
28+
contains(github.event.workflow_run.pull_requests.*.labels.*.name, 'deploy-pr-doc')
29+
) || (
30+
github.event_name == 'pull_request' &&
31+
github.event.action == 'closed' &&
32+
contains(github.event.pull_request.labels.*.name, 'deploy-pr-doc')
33+
)
2534
steps:
26-
- name: "Download artifacts"
35+
- name: Set PR number
36+
id: pr
37+
run: |
38+
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
39+
echo "pr_number=${{ fromJson(toJson(github.event.workflow_run.pull_requests[0])).number }}" >> "$GITHUB_OUTPUT"
40+
else
41+
echo "pr_number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
42+
fi
43+
44+
- name: Print PR number
45+
run: echo "PR number is ${{ steps.pr.outputs.pr_number }}"
46+
47+
- name: Download artifacts (if workflow_run)
48+
if: ${{ github.event_name == 'workflow_run' }}
2749
uses: dawidd6/action-download-artifact@v11
2850
with:
2951
workflow: docs.yml
3052
name: HTML-doc-ansys-dpf-core.zip
3153
github_token: ${{ secrets.GITHUB_TOKEN }}
3254
run_id: ${{ github.event.workflow_run.id }}
3355

34-
35-
- name: "Display downloaded files"
56+
- name: Display downloaded files (if workflow_run)
57+
if: ${{ github.event_name == 'workflow_run' }}
3658
run: ls -R
3759

38-
- uses: ansys/actions/doc-deploy-pr@v10
60+
- name: Deploy PR documentation
61+
uses: ansys/actions/doc-deploy-pr@v10
3962
with:
4063
cname: ${{ env.DOCUMENTATION_CNAME }}
4164
token: ${{ secrets.GITHUB_TOKEN }}
4265
doc-artifact-name: HTML-doc-ansys-dpf-core.zip
4366
decompress-artifact: true
4467
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
4568
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
46-
maximum-pr-doc-deployments: 10
69+
maximum-pr-doc-deployments: 10

0 commit comments

Comments
 (0)