This GitHub Action runs Sentiment Analysis over the built text of your GitHub project. It uses Google's analyzeSentiment API, evaluating the overall emotion score (from positive to negative) of a page. The Action provides an overview of the scores of all the pages from your project (more on interpreting the scores).
This is a workflow example of using the Action on plain .html
files from the public
folder (by default).
name: Sentiment analysis on public
on: push
jobs:
analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 #Be sure you checkout the files beforehand
- name: Run sentiment analysis on HTML files
uses: bogdaaamn/[email protected]
with:
gcp_key: ${{ secrets.GCP_KEY }} #Google Cloud Platform API key. Read the README for instructions
Although, if you project needs to be built beforehand, be sure you place the Action after the building step. Here is an example for React.
name: Sentiment analysis on React
on: push
jobs:
analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 #Be sure you checkout the files beforehand
- name: Build and test #Build the HTML files beforehand.
run: |
npm ci
npm run build
npm test
- name: Run sentiment analysis on HTML files
uses: bogdaaamn/[email protected]
with:
gcp_key: ${{ secrets.GCP_KEY }} #Google Cloud Platform API key. Read the README for instructions
files: "build/**/*.html" #Glob patterns from files to be analayzed. Read the README for instructions
The examples above use required input gcp_key
. Because the Actions uses the Google API you need generate a key on your own as it follows:
- Log into Google Cloud Platform Console;
- Navigate to the menu and click on API&Services > Credentials;
- Click on CREATE CREDENTIALS > API Key;
- When API key created modal is promted, copy the freshly created key.
Read more about Creating API Keys.
- On your project's page click on the Settings button;
- Navigate to Secrets panel;
- Click on New secret;
- Name it GCP_KEY and paste the key there.
๐ Now you can use the key in your project's Actions as ${{ secrets.GCP_KEY }}
. Read more about GitHub Secrets.
The files
input is the glob pattern of paths for the files that the Action should analyze. By default it is set to public/**/*.html
, meaning that will check for all the files with .html
extension in all the directories in the public
directory.
Read more, and understand glob patterns and their limitations on @actions/glob
.
This an early release of the Action. The roadmap of known issues and features will be updated here.
- Parse and merge more content tags:
โ ๏ธ For now, this Action takes into account only<p>
HTML tags. As more use cases will be tested, more tags will be included, along with the possibility of customization. - Custom score threshold: The overview table printed as a result of the Action highlights with color the very negative and very positive documents. At the moment, the threshold of the emotion score is predefined at
ยฑ0.5
. The next release will allow the user to define the threshold so they can get a custom color-coded table. - Split the base directory of the path: At this moment, the overview table prints only the name of the file, creating confusion between files with the same name in different directories. In the next release, the table will print the relative path of the file.