Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Add Github Actions support #160

Merged
merged 12 commits into from Sep 16, 2020
1 change: 1 addition & 0 deletions lib/detect.js
Expand Up @@ -16,6 +16,7 @@ var services = {
heroku: require('./services/heroku'),
teamcity: require('./services/teamcity'),
codebuild: require('./services/codebuild'),
github_actions: require('./services/github_actions'),
}

var detectProvider = function() {
Expand Down
15 changes: 15 additions & 0 deletions lib/services/github_actions.js
@@ -0,0 +1,15 @@
module.exports = {
detect: function() {
return !!process.env.GITHUB_ACTIONS
},

configuration: function() {
console.log(' GitHub Actions CI Detected')
return {
service: 'github_actions',
ibrahim0814 marked this conversation as resolved.
Show resolved Hide resolved
commit: process.env.GITHUB_SHA,
branch: process.env.GITHUB_REF.replace("refs/heads/", ""),
slug: process.env.GITHUB_REPOSITORY,
}
},
}
21 changes: 21 additions & 0 deletions test/services/github_actions.test.js
@@ -0,0 +1,21 @@
var github_actions = require('../../lib/services/github_actions')

describe('GitHub Actions CI Provider', function() {
it('can detect GitHub Actions', function() {
process.env.GITHUB_ACTIONS = '1'
expect(github_actions.detect()).to.be(true)
ibrahim0814 marked this conversation as resolved.
Show resolved Hide resolved
})

it('can get GitHub Actions env info', function() {
process.env.GITHUB_SHA = '743b04806ea677403aa2ff26c6bdeb85005de658'
process.env.GITHUB_REPOSITORY = 'codecov/codecov-repo'
process.env.GITHUB_REF = 'refs/heads/master'

expect(github_actions.configuration()).to.eql({
ibrahim0814 marked this conversation as resolved.
Show resolved Hide resolved
service: 'github_actions',
ibrahim0814 marked this conversation as resolved.
Show resolved Hide resolved
commit: '743b04806ea677403aa2ff26c6bdeb85005de658',
branch: 'master',
slug: 'codecov/codecov-repo',
})
})
})