Skip to content

Commit 9fe0e3c

Browse files
committed
Run sbt submitDependencyGraph
1 parent 96941c8 commit 9fe0e3c

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jobs:
1010
test:
1111
name: Test on ${{ matrix.os }}
1212
runs-on: ${{ matrix.os }}
13+
env:
14+
GITHUB_TOKEN: ${{ github.token }}
1315
strategy:
1416
fail-fast: false
1517
matrix:
@@ -18,5 +20,7 @@ jobs:
1820
- uses: actions/checkout@v2
1921
- run: npm install
2022
- run: npm run all
23+
- name: Create sbt build
24+
run: mkdir project
2125
- name: Run sbt-dependency-graph-action
2226
uses: ./

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ branding:
55
icon: 'package'
66
color: '#1a84ac'
77
runs:
8-
using: 'node12'
8+
using: 'node16'
99
main: 'dist/index.js'

src/main.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,40 @@
1+
import * as cli from '@actions/exec'
12
import * as core from '@actions/core'
3+
import * as crypto from 'crypto'
4+
import * as fs from 'fs'
5+
import * as fsPromises from 'fs/promises'
6+
import * as os from 'os'
7+
import * as path from 'path'
8+
9+
// Version of the sbt-dependency-graph-plugin
10+
const pluginVersion = '0.1.0-M5'
11+
const baseDir = '.'
12+
13+
async function commandExists(cmd: string): Promise<boolean> {
14+
const isWin = os.platform() === 'win32'
15+
const where = isWin ? 'where.exe' : 'which'
16+
const code = await cli.exec(where, [cmd], { silent: true })
17+
return code === 0
18+
}
219

320
async function run(): Promise<void> {
421
try {
5-
core.info('Hello, World!')
22+
const projectDir = path.join(baseDir, 'project')
23+
const uuid = crypto.randomUUID()
24+
const pluginFile = path.join(projectDir, `github-dependency-graph-${uuid}.sbt`)
25+
const pluginDep = `addSbtPlugin("ch.epfl.scala" % "sbt-github-dependency-graph" % "${pluginVersion}")`
26+
const isProject = fs.existsSync(projectDir)
27+
if (!isProject) {
28+
core.setFailed(`${baseDir} is not a valid sbt project: missing folder '${projectDir}'.`)
29+
return
30+
}
31+
await fsPromises.writeFile(pluginFile, pluginDep)
32+
const sbtExists = await commandExists('sbt')
33+
if (!sbtExists) {
34+
core.setFailed('Not found sbt command')
35+
return
36+
}
37+
await cli.exec('sbt', ['submitGithubDependencyGraph'])
638
} catch (error) {
739
if (error instanceof Error) {
840
core.setFailed(error)

0 commit comments

Comments
 (0)