-
Notifications
You must be signed in to change notification settings - Fork 23
ci(doc): Switch doc-deploy-pr to a dedicated workflow #2529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2529 +/- ##
=======================================
Coverage 84.12% 84.12%
=======================================
Files 91 91
Lines 10703 10703
=======================================
Hits 9004 9004
Misses 1699 1699 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PProfizi nice approach. I didn't even know an action exist for downloading artifacts from other workflows. I made some suggestions, especially wrt the need for the closed event to be present.
I still have a concern:
I think this shouldn't need to be on main before we can confirm that it works because reusable workflows are picked up from the current branch, the reason it currently doesn't get triggered might be because we run docs.yml
from ci.yml
, and it may not be considered valid for the workflow_run
trigger. I may be wrong.
name: doc-deploy-PR | ||
|
||
on: | ||
workflow_run: | ||
workflows: [docs] | ||
types: [completed] | ||
|
||
env: | ||
DOCUMENTATION_CNAME: 'dpf.docs.pyansys.com' | ||
|
||
jobs: | ||
debug: | ||
name: debug | ||
runs-on: ubuntu-latest | ||
env: | ||
EVENT_OBJ: ${{ toJson(github.event) }} | ||
steps: | ||
- run: echo $EVENT_OBJ | ||
doc-deploy-pr: | ||
name: "Deploy PR documentation" | ||
runs-on: ubuntu-latest | ||
if: | | ||
github.event.workflow_run.conclusion == 'success' && | ||
contains(github.event.workflow_run.pull_requests.*.labels.*.name, 'deploy-pr-doc') | ||
steps: | ||
- name: "Download artifacts" | ||
uses: dawidd6/action-download-artifact@v11 | ||
with: | ||
workflow: docs.yml | ||
name: HTML-doc-ansys-dpf-core.zip | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
run_id: ${{ github.event.workflow_run.id }} | ||
|
||
|
||
- name: "Display downloaded files" | ||
run: ls -R | ||
|
||
- uses: ansys/actions/doc-deploy-pr@v10 | ||
with: | ||
cname: ${{ env.DOCUMENTATION_CNAME }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
doc-artifact-name: HTML-doc-ansys-dpf-core.zip | ||
decompress-artifact: true | ||
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} | ||
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} | ||
maximum-pr-doc-deployments: 10 No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name: doc-deploy-PR | |
on: | |
workflow_run: | |
workflows: [docs] | |
types: [completed] | |
env: | |
DOCUMENTATION_CNAME: 'dpf.docs.pyansys.com' | |
jobs: | |
debug: | |
name: debug | |
runs-on: ubuntu-latest | |
env: | |
EVENT_OBJ: ${{ toJson(github.event) }} | |
steps: | |
- run: echo $EVENT_OBJ | |
doc-deploy-pr: | |
name: "Deploy PR documentation" | |
runs-on: ubuntu-latest | |
if: | | |
github.event.workflow_run.conclusion == 'success' && | |
contains(github.event.workflow_run.pull_requests.*.labels.*.name, 'deploy-pr-doc') | |
steps: | |
- name: "Download artifacts" | |
uses: dawidd6/action-download-artifact@v11 | |
with: | |
workflow: docs.yml | |
name: HTML-doc-ansys-dpf-core.zip | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
run_id: ${{ github.event.workflow_run.id }} | |
- name: "Display downloaded files" | |
run: ls -R | |
- uses: ansys/actions/doc-deploy-pr@v10 | |
with: | |
cname: ${{ env.DOCUMENTATION_CNAME }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
doc-artifact-name: HTML-doc-ansys-dpf-core.zip | |
decompress-artifact: true | |
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} | |
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} | |
maximum-pr-doc-deployments: 10 | |
name: doc-deploy-PR | |
on: | |
workflow_run: | |
workflows: [docs] | |
types: [completed] | |
pull_request: | |
types: [closed] | |
env: | |
DOCUMENTATION_CNAME: 'dpf.docs.pyansys.com' | |
jobs: | |
debug: | |
name: debug | |
runs-on: ubuntu-latest | |
env: | |
EVENT_OBJ: ${{ toJson(github.event) }} | |
steps: | |
- run: echo $EVENT_OBJ | |
doc-deploy-pr: | |
name: "Deploy PR documentation" | |
runs-on: ubuntu-latest | |
if: | | |
( | |
github.event_name == 'workflow_run' && | |
github.event.workflow_run.conclusion == 'success' && | |
contains(github.event.workflow_run.pull_requests.*.labels.*.name, 'deploy-pr-doc') | |
) || ( | |
github.event_name == 'pull_request' && | |
github.event.action == 'closed' && | |
contains(github.event.pull_request.labels.*.name, 'deploy-pr-doc') | |
) | |
steps: | |
- name: Set PR number | |
id: pr | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then | |
echo "pr_number=${{ fromJson(toJson(github.event.workflow_run.pull_requests[0])).number }}" >> "$GITHUB_OUTPUT" | |
else | |
echo "pr_number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Print PR number | |
run: echo "PR number is ${{ steps.pr.outputs.pr_number }}" | |
- name: Download artifacts (if workflow_run) | |
if: ${{ github.event_name == 'workflow_run' }} | |
uses: dawidd6/action-download-artifact@v11 | |
with: | |
workflow: docs.yml | |
name: HTML-doc-ansys-dpf-core.zip | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
run_id: ${{ github.event.workflow_run.id }} | |
- name: Display downloaded files (if workflow_run) | |
if: ${{ github.event_name == 'workflow_run' }} | |
run: ls -R | |
- uses: ansys/actions/doc-deploy-pr@v10 | |
with: | |
cname: ${{ env.DOCUMENTATION_CNAME }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
doc-artifact-name: HTML-doc-ansys-dpf-core.zip | |
decompress-artifact: true | |
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} | |
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} | |
maximum-pr-doc-deployments: 10 |
According to the doc you can trigger up to 3 workflows in a sequence this way |
Hi @PProfizi, I just saw the section in the docs where it was stated that the workflow has to be on the default branch for this to work.. :) |
Moves the
doc-deploy-pr
action to a dedicated workflow triggered by aworkflow_run
completed
ondocs.yml
, and deploying only if the PR is labeled withdeploy-pr-doc
.The new workflow needs to be present in the main branch to be triggered.