workflows: allure: separate main branch from others #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Allure Reports to GitHub Pages | |
on: | |
workflow_call: | |
push: | |
env: | |
GHPAGES_LABEL: "gh-pages" | |
jobs: | |
allure-collect-and-publish: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: publish_allure_to_gh_pages | |
cancel-in-progress: false | |
steps: | |
- name: Load Allure report history | |
uses: actions/checkout@v4 | |
continue-on-error: true | |
with: | |
repository: golioth/allure-reports | |
ref: ${{ env.GHPAGES_LABEL }} | |
path: ${{ env.GHPAGES_LABEL }} | |
ssh-key: ${{ secrets.ALLURE_REPORTS_DEPLOY_KEY }} | |
- name: Collect individual reports | |
uses: actions/download-artifact@v4 | |
with: | |
path: reports/allure-results | |
pattern: allure-reports-* | |
merge-multiple: true | |
- name: Upload collected reports | |
uses: actions/upload-artifact@v4 | |
with: | |
name: allure-reports-alltest | |
path: reports/allure-results | |
- name: Setup Allure Branch Awareness | |
id: vars | |
run: | | |
if [[ $GITHUB_REF_NAME == 'main' ]]; then | |
echo "allure_subdir=main" >> $GITHUB_OUTPUT | |
else | |
echo "allure_subdir=branch" >> $GITHUB_OUTPUT | |
fi | |
- name: Build Allure report | |
uses: szczys/allure-report-action@fix-workflow-url-when-hosted-remotely | |
if: always() | |
with: | |
gh_pages: ${{ env.GHPAGES_LABEL }} | |
allure_history: reports/allure-history | |
allure_results: reports/allure-results | |
github_repo: golioth/allure-reports | |
github_repo_owner: golioth | |
subfolder: ${{ steps.vars.outputs.allure_subdir}} | |
- name: Rsync the Allure build | |
run: | | |
rsync -a \ | |
reports/allure-history/${{ steps.vars.outputs.allure_subdir}} \ | |
${{ env.GHPAGES_LABEL }} \ | |
--delete | |
- name: Place index.html | |
if: always() && github.ref == 'refs/heads/main' | |
# Root URL should always point to latest main report | |
run: cp reports/allure-history/${{ steps.vars.outputs.allure_subdir}}/index.html \ | |
${{ env.GHPAGES_LABEL }}/. | |
- name: Publish test report | |
uses: peaceiris/actions-gh-pages@v4 | |
if: always() | |
with: | |
deploy_key: ${{ secrets.ALLURE_REPORTS_DEPLOY_KEY }} | |
external_repository: golioth/allure-reports | |
publish_branch: ${{ env.GHPAGES_LABEL }} | |
publish_dir: ${{ env.GHPAGES_LABEL }} | |
- name: Add Allure link to summary | |
run: | | |
echo "### Allure Report" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "- [Workflow ${{ github.run_number }}]\ | |
(https://golioth.github.io/allure-reports/${{ steps.vars.outputs.allure_subdir}}/${{ github.run_number }}/)" \ | |
>> $GITHUB_STEP_SUMMARY |