Skip to content

Commit

Permalink
Merge pull request #4 from MeilCli/update
Browse files Browse the repository at this point in the history
update action
  • Loading branch information
MeilCli authored Mar 13, 2020
2 parents b400f89 + 159d487 commit 88dcad6
Show file tree
Hide file tree
Showing 23 changed files with 541 additions and 356 deletions.
6 changes: 2 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"plugin:prettier/recommended",
"prettier/@typescript-eslint"
],
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"env": {
"node": true,
"es6": true
Expand All @@ -27,4 +25,4 @@
}
]
}
}
}
19 changes: 13 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ name: CI
on:
push:
branches:
- master
- master
pull_request:
branches:
- master
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
Expand All @@ -26,18 +26,25 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- name: npm install
run: |
npm install
run: npm install
env:
CI: true
- uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Bundle config
run: bundle config path vendor/bundle
- uses: MeilCli/danger-action@master
with:
plugins_file: 'Gemfile'
Expand Down
41 changes: 27 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,30 @@ on:
jobs:
danger:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' # if only run pull request when multiple trigger workflow
steps:
- uses: actions/checkout@v1
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- uses: MeilCli/danger-action@v2
with:
plugins_file: 'Gemfile'
danger_file: 'Dangerfile'
danger_id: 'danger-pr'
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
# ↓↓↓ if using bundle cache when danger plugins install ↓↓↓
- uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile') }} # change your gemfile path
restore-keys: |
${{ runner.os }}-gems-
- name: Bundle config
run: bundle config path vendor/bundle
# ↑↑↑ if using bundle cache when danger plugins install ↑↑↑
- uses: MeilCli/danger-action@v3
with:
plugins_file: 'Gemfile'
danger_file: 'Dangerfile'
danger_id: 'danger-pr'
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
- if multiple trigger workflow, use if condition `if: github.event_name == 'pull_request'`
- example is [this repository's workflow](.github/workflows/build.yml)
## input
- `danger_version`
Expand All @@ -42,13 +51,17 @@ jobs:
- default: `>= 6.0.0`
- `plugins_file`
- optional
- gemfile path for danger plugin
- gemfile path for danger plugin. if set plugins_file, action do not exec `gem install danger`
- `danger_file`
- required
- dangerfile path for running danger
- `danger_id`
- required
- danger id is an identifier string, example(`danger-pr`, `danger-CI`, etc..)
- `fail_on_stderr_when_danger`
- optional
- action fail when danger output stderr
- default: `false`

## env
- `DANGER_GITHUB_API_TOKEN`
Expand Down
26 changes: 19 additions & 7 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ function getOption() {
dangerVersion: core.getInput("danger_version", { required: true }),
pluginsFile,
dangerFile: core.getInput("danger_file", { required: true }),
dangerId: core.getInput("danger_id", { required: true })
dangerId: core.getInput("danger_id", { required: true }),
failOnStdErrWhenDanger: core.getInput("fail_on_stderr_when_danger") == "true"
};
});
}
Expand All @@ -41,9 +42,13 @@ function checkEnvironment() {
}
function installDanger(option) {
return __awaiter(this, void 0, void 0, function* () {
yield exec.exec(`gem install danger --version "${option.dangerVersion}"`, undefined, { failOnStdErr: true });
if (option.pluginsFile != null) {
yield exec.exec(`bundle install --gemfile=${option.pluginsFile}`, undefined, { failOnStdErr: true });
if (option.pluginsFile == null) {
yield exec.exec(`gem install danger --version "${option.dangerVersion}"`, undefined, { failOnStdErr: true });
}
else {
yield exec.exec(`bundle install --gemfile=${option.pluginsFile} --jobs 4 --retry 3`, undefined, {
failOnStdErr: true
});
}
});
}
Expand All @@ -55,9 +60,16 @@ function ignoreRubyWarning() {
}
function runDanger(option) {
return __awaiter(this, void 0, void 0, function* () {
yield exec.exec(`danger --dangerfile=${option.dangerFile} --danger_id=${option.dangerId}`, undefined, {
failOnStdErr: true
});
if (option.pluginsFile == null) {
yield exec.exec(`danger --dangerfile=${option.dangerFile} --danger_id=${option.dangerId}`, undefined, {
failOnStdErr: option.failOnStdErrWhenDanger
});
}
else {
yield exec.exec(`bundle exec danger --dangerfile=${option.dangerFile} --danger_id=${option.dangerId}`, undefined, {
failOnStdErr: option.failOnStdErrWhenDanger
});
}
});
}
function run() {
Expand Down
6 changes: 6 additions & 0 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions node_modules/@actions/core/lib/command.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 29 additions & 17 deletions node_modules/@actions/core/lib/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@actions/core/lib/command.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions node_modules/@actions/core/lib/core.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions node_modules/@actions/core/lib/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@actions/core/lib/core.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 88dcad6

Please sign in to comment.