By default, GitHub Actions does not expose the required environment variables for branch name and Commit SHA: GIT_COMMIT_SHA
and GIT_BRANCH
.
-
More information on branch names is available at this post: https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions
-
Additionally, check out the open issue on our test reporter repo: https://github.com/codeclimate/test-reporter/issues/406
For GitHub Actions, many users have made use of the GitHub Action located here: https://github.com/paambaati/codeclimate-action. This action exposes the correct ENV variables, executes the Code Climate test reporter, and uploads coverage information Code Climate.
Example 1
https://github.com/paambaati/websight/blob/master/.github/workflows/ci.yml
name: build
on:
push:
branches:
- master
tags:
- '!*' # Do not execute on tags
paths:
- src/*
- test/*
- '*.json'
- yarn.lock
pull_request:
paths:
- '!*.MD'
jobs:
test:
strategy:
matrix:
platform: [ ubuntu-latest, macOS-latest ]
node: [ '12', '10' ]
name: test/node ${{ matrix.node }}/${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
- run: npm install -g yarn
- run: yarn install
- run: yarn build
- run: yarn test
coverage:
needs: [ test ]
name: coverage
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: '12'
- run: npm install -g yarn
- run: yarn install
- run: yarn build
- uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: 945dfb58a832d233a3caeb84e3e6d3be212e8c7abcb48117fce63b9adcb43647
with:
coverageCommand: yarn coverage
Updated about a year ago