---
title: Publishing Reports to GitHub Pages
description: Learn how to integrate Allure Report with GitHub Pages. Automate test report generation and publishing with simple workflow configuration.
---

# Publishing Reports to GitHub Pages (Allure 2)

With the Allure Report plugin for GitHub Actions, you can automatically generate test reports and publish them to GitHub Pages.

To enable Allure support in your Bamboo installation, do the following under the repository's administrator account:

1. [add actions for building and publishing reports](#_1-add-actions-for-building-and-publishing-reports).
2. [enable write access for workflow runs](#_2-enable-write-access-for-workflow-runs),
3. [set up publishing to GitHub Pages](#_3-set-up-publishing-to-github-pages).

## 1. Add actions for building and publishing reports

At the end of your repository's testing workflow, add three new steps that will [load test report history](#load-test-report-history), [build test report](#build-test-report) and [publish test report](#publish-test-report).

See below for more details on each step and its parameters.

Details:

Here is a full example of a workflow file for a Java project. The example assumes that the branch used for GitHub Pages is called `gh-pages`.

```yaml
name: Run tests and publish report
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Set up JDK
        uses: actions/setup-java@v3
        with:
          distribution: zulu
          java-version: 17

      - name: Run tests
        run: ./gradlew clean test

      - name: Load test report history
        uses: actions/checkout@v3
        if: always()
        continue-on-error: true
        with:
          ref: gh-pages
          path: gh-pages

      - name: Build test report
        uses: simple-elf/allure-report-action@v1.7
        if: always()
        with:
          gh_pages: gh-pages
          allure_history: allure-history
          allure_results: build/allure-results

      - name: Publish test report
        uses: peaceiris/actions-gh-pages@v3
        if: always()
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_branch: gh-pages
          publish_dir: allure-history
```

### Load test report history

As discussed in [Tests history](/docs/history-and-retries/#tests-history), Allure Report can include some data from previous reports into each new report. To do so, you need to provide it with the files published on GitHub Pages by previous runs. This step does it by doing a `git checkout` from the branch used for the GitHub Pages content.

In the workflow file, set the following values for this step:

- `name`: any human-redable name, e.g., “Load test report history”.
- `uses`: [`actions/checkout@v2`](https://github.com/marketplace/actions/checkout).
- `if`: `always()`.
- `continue-on-error`: `true`.
- `with`:
  - `ref`: the branch used for the GitHub Pages content.
  - `path`: an arbitrary name for a directory to which the previous data will be saved.

### Build test report

This step runs the Allure Report utility to build an HTML report, based on data from both the current and previous test launches. The new report, along with the copies of previous reports, will be saved into the directory specified in `allure_history`, ready to be published to GitHub Pages.

In the workflow file, set the following values for this step:

- `name`: any human-readable name, e.g., “Build test report”.
- `uses`: [`simple-elf/allure-report-action@v1.7`](https://github.com/marketplace/actions/allure-report-with-history).
- `if`: `always()`.
- `with`:
  - `gh_pages`: the directory name to which the previous data was downloaded. Must be the same as the `path` value from the [Load test reports history](#load-test-report-history) step.
  - `allure_results`: path to the current test results directory. Depending on the framework you use and the Allure integration configuration, an appropriate path may be `allure-results`, `build/allure-results`, or some custom path.
  - `allure_history`: an arbitrary name for a directory to which the result will be saved.

### Publish test report

The final step of the workflow will push the generated directory to the branch used for GitHub Pages. This is supposed to trigger a second workflow run, called “pages build and deployment”, which, in turn, will update the actual contents on the GitHub Pages domain. (See [Set up publishing to GitHub Pages](#_3-set-up-publishing-github-pages) below.)

In the workflow file, set the following values for this step:

- `name`: any human-redable name, e.g., “Publish test report”.
- `uses`: [`peaceiris/actions-gh-pages@v3`](https://github.com/marketplace/actions/github-pages-action).
- `if`: `always()`.
- `with`:
  - `github_token`: `${{ secrets.GITHUB_TOKEN }}`. See [Enable write access for GitHub Actions](#_2-enable-write-access-for-workflow-runs) for more details.
  - `publish_branch`: the branch used for the GitHub Pages content.
  - `publish_dir`: the directory to be published. Must be the same as the `allure_history` value from the [Build test report](#build-test-report) step.

## 2. Enable write access for workflow runs

When pushing files to the GitHub Pages branch, the workflow uses an authentication token generated by GitHub. However, the default configuration does not allow GitHub Actions to push files to the repository, and you may find errors like this in your workflow run's logs:

```plain
remote: Permission to ⟨USER⟩/⟨REPOSITORY⟩.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/⟨USER⟩/⟨REPOSITORY⟩.git/':
The requested URL returned error: 403
```

To fix this, you need to grant write permissions to the token.

1. On the project's page on GitHub, go to **Settings → Actions → General**.

1. Under the **Workflow permissions** section, select the **Read and write permissions** option.

1. Click **Save**.

![Allure Github configure workflow permissions](/images/integrations/github/permissions.png "Allure Github configure workflow permissions")

## 3. Set up publishing to GitHub Pages

After you've run the workflow for the first time, it will push the test report to a branch but will not actually publish it. For the report to be published, you need to enable an automatic second workflow settings.

1. Make sure that the branch with the content exists (`gh-pages` in the example above).

1. On the project's page on GitHub, go to **Settings → Pages**.

1. Under the **Build and deployment** section, specify the options:

   - **Source**: “Deploy from a branch”.
   - **Branch**: the branch used for the GitHub Pages content. In the next dropdown list, select “/ (root)”.

1. Click **Save**.

1. Go to the **Actions** tab.

1. Make sure that the workflow run called “pages build and deployment” was automatically created.

   Once the run is completed, the test report should appear on the GitHub Pages domain.

![Allure Github configure github pages](/images/integrations/github/pages.png "Allure Github configure github pages")
