88
99# Best Practice: Prevent race conditions on the gh-pages branch
1010concurrency :
11- group : ${{ github.workflow }}-${{ github.head_ref || github.ref }}
11+ group : " pages "
1212 cancel-in-progress : true
1313
1414# These permissions are required for the actions to post comments and push to the gh-pages branch
1515permissions :
16- contents : write
17- pull-requests : write
16+ contents : read
17+ pages : write
18+ id-token : write
1819
1920jobs :
20- build-and-report :
21+ build :
2122 runs-on : ubuntu-latest
2223 steps :
2324 - name : Checkout code
@@ -34,47 +35,42 @@ jobs:
3435 - name : Install dependencies
3536 run : poetry install --no-interaction --no-ansi
3637
38+ - name : Install Allure Commandline
39+ run : |
40+ wget https://github.com/allure-framework/allure2/releases/download/2.29.0/allure-2.29.0.tgz
41+ sudo tar -zxvf allure-2.29.0.tgz -C /opt/
42+ sudo ln -s /opt/allure-2.29.0/bin/allure /usr/bin/allure
43+ allure --version
44+
3745 - name : Run CI Pipeline (Lint, Typecheck, Test)
3846 # This runs all checks and generates the raw 'allure-results'
3947 run : poetry run task ci
4048
41- - name : Check out gh-pages branch
42- uses : actions/checkout@v4
43- if : always()
44- continue-on-error : true # This allows the workflow to continue if the branch doesn't exist yet
45- with :
46- ref : gh-pages
47- path : gh-pages
49+ - name : Build Allure Report
50+ # This creates the 'test/allure-report' directory
51+ run : poetry run task post_test
4852
49- - name : Generate Allure Report with History
50- uses : mgrybyk-org/allure-report-branch-js-action@v1
51- # This is crucial: The report should be generated even if tests fail
52- if : always()
53- # Give the step an ID so we can reference its outputs later
54- id : allure_report
55- with :
56- # The folder where raw Allure results are stored
57- report_dir : ' test/allure/results'
58- gh_pages : ' gh-pages'
53+ - name : Set up Pages
54+ # This action prepares the artifact for deployment
55+ uses : actions/configure-pages@v5
5956
60- - name : Commit and Push Report
61- uses : mgrybyk-org/git-commit-pull-push- action@v1
62- if : always() && github.ref == 'refs/heads/main' # Only push on merge to main
57+ - name : Upload artifact
58+ # This action uploads the report as a Pages artifact
59+ uses : actions/upload-pages-artifact@v3
6360 with :
64- repository : gh-pages # The directory with the checked-out branch
65- branch : gh-pages # The branch to push to
66- # This handles potential merge conflicts by favoring the new report
67- pull_args : --rebase -X ours
68- - name : Comment on Pull Request with Report Link
69- # Only run this step for pull request events
70- if : github.event_name == 'pull_request'
71- uses : thollander/actions-comment-pull-request@v2
72- with :
73- # Use the outputs from the previous step to build a nice message
74- message : |
75- ${{ steps.allure_report.outputs.test_result_icon }} **Allure Test Report** is ready!
61+ path : ' ./test/allure/reports'
7662
77- * **Report Link:** ${{ steps.allure_report.outputs.report_url }}
78- * **History:** ${{ steps.allure_report.outputs.report_history_url }}
79- # This tag allows the action to update its own comment instead of creating new ones
80- comment_tag : allure_report
63+ # This job deploys the report
64+ deploy :
65+ # It requires the 'build' job to finish successfully
66+ needs : build
67+ # Only run this job on pushes to the main branch
68+ if : github.ref == 'refs/heads/main'
69+ runs-on : ubuntu-latest
70+ environment :
71+ name : github-pages
72+ url : ${{ steps.deployment.outputs.page_url }}
73+ steps :
74+ - name : Deploy to GitHub Pages
75+ id : deployment
76+ uses : actions/deploy-pages@v4
0 commit comments