How to upload artifacts in GitHub?


When a GitHub Actions workflow completes a build successfully, artifacts such as zip files, compiled code, Java JAR files, and other assembled components are created. Once the workflow is completed, the Docker container on which the GitHub Actions artifacts are created vanishes. However, it is not difficult for a developer to request that GitHub archive those artifacts and make them available as a downloadable link.

Steps to publish GitHub Action Artifact

  1. Complete the GitHub Actions build steps. Add a stage for the Artifact – Test Report upload.

2. Enter the path to the files that must be uploaded. I’m copying all the files generated by Serenity that are in the target/site/serenity folder.

3. Use GitHub’s upload-artifact action to download all the files in the serenity folder and compress them into a zip file called Serenity

4. Run the GitHub Actions workflow and look for the published artifacts on the build page of the workflow.

How to create a GitHub Action?

Please refer to this tutorial to understand the steps to create a GitHub Action – How to run Selenium tests with GitHub Actions.

GitHub Action Artifact YAML Example

If the previous step is failed, and we still want to proceed to the next step, then use the below status syntax:

if: success() || failure()

To read more about the status check function, you can refer to this.

name: Serenity Rest Assured with JUnit4

    branches: [ "main" ]
    branches: [ "main" ]


    runs-on: ubuntu-latest

    - uses: actions/checkout@v3
    - name: Set up JDK 11
      uses: actions/setup-java@v3
        java-version: '11'
        distribution: 'temurin'
        cache: maven
    - name: Build with Maven
      run: mvn clean verify
    - name: Test Report
      uses: actions/upload-artifact@v3
      if: success() || failure()
          name: Serenity Report               # Name of the folder
          path: target/site/serenity/           # Path to test results

Published artifacts on GitHub

From the logs of the Workflow, you can see that the Test Report step was executed successfully.

Once the pipeline run, a Serenity Report folder will be generated as shown in the below image:

When we click on the folder Serenity Report, a zipped file will be downloaded, and we can extract it to see all the files contained within it.

You can see the GitHub pipeline here – GitHub Artifact Upload.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s