Skip to content

edunad/actions-image

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

actions-image

Post a image on the pull request. Usefull for screenshots of failed E2E tests. Also supports tagging code files.

Requirements

If you encounter the "Resource not accessible by integration" you need to add the following permissions:

permissions:
    contents: write
    actions: read
    checks: write

Inputs

GITHUB_TOKEN - REQUIRED

The github token to perform api actions, can be set to ${{GITHUB_TOKEN}} or a custom one.

path - REQUIRED

The path to the image files, it supports glob. (Ex: ./my-image/**/*.png)

title - OPTIONAL

The title to display on the annotations (Ex: Failed E2E Tests)

uploadHost - OPTIONAL

Where to upload the pictures to (Default: https://litterbox.catbox.moe/resources/internals/api.php , please do not upload sensitive information, this is public access), uses form POST to upload.

annotationTag - OPTIONAL

The tag that is used to split the base64 image info (Default: [==] Ex: tests/mytest.spec.js[--]80:40.png)

annotationLevel - OPTIONAL

The annotation level | Supported values: notice, warning, failure (Default: notice)


Example usage

- name: Upload failed tests
  if: ${{ failure() }}
  uses: edunad/[email protected]
  with:
      path: './failed_tests/**/*.png'
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      title: 'Failed E2E tests 🙀'
      annotationLevel: 'failure'

How to tag images on code

Save your image name with following format and convert it to base64

filePath[==]line:column

For example :

tests/mycode/basic-test.spec.js[==]80:30

Then on NodeJS save the image as

const fs = require('fs');
const imageName = Buffer.from(`tests/mycode/basic-test.spec.js[==]80:30`).toString('base64');

fs.writeFileSync(`${imageName}.png`, ...etc)

It will then apply the add an annotation like