Skip to content

Commit

Permalink
CI: run rspec in GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
YusukeHosonuma committed Feb 16, 2020
1 parent c0196f5 commit 9b3b0d1
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 23 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Run danger

on: [pull_request]

jobs:
build:

# Note:
# Maybe can use linux image
runs-on: macos-latest

steps:
- uses: actions/checkout@v2

- name: Cache bundler
uses: actions/cache@v1
with:
path: vendor/bundle
key: bundler-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
bundler-${{ hashFiles('Gemfile.lock') }}
- name: Setup
run: |
bundle
# Note:
# Run only PR in own repository.
# Because can't push to forked repository.
- name: Run rubocop --auto-correct and push
if: contains(github.event.pull_request.head.repo.clone_url, github.repository)
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
git config --global user.name 'Yusuke Hosonuma'
git config --global user.email '[email protected]'
git checkout -b ${{ github.head_ref }} origin/${{ github.head_ref }}
bundle exec rubocop --auto-correct && true
git add -u
git diff-index --quiet HEAD -- || git commit -m '[ci skip] $ rubocop --auto-correct'
git push
# Note:
# Run only PR in own repository.
# Because can't comment to PR from danger. (Maybe you can... ?)
- name: Run danger
if: contains(github.event.pull_request.head.repo.clone_url, github.repository)
run: |
bundle exec danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 4 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Run danger
name: Test

on: [pull_request]
on: [push]

jobs:
build:
Expand All @@ -24,28 +24,9 @@ jobs:
run: |
bundle
# Note:
# Run only PR in own repository.
# Because can't push to forked repository.
- name: Run rubocop --auto-correct and push
if: contains(github.event.pull_request.head.repo.clone_url, github.repository)
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
git config --global user.name 'Yusuke Hosonuma'
git config --global user.email '[email protected]'
git checkout -b ${{ github.head_ref }} origin/${{ github.head_ref }}
bundle exec rubocop --auto-correct && true
git add -u
git diff-index --quiet HEAD -- || git commit -m '[ci skip] $ rubocop --auto-correct'
git push
# Note:
# Run only PR in own repository.
# Because can't comment to PR from danger. (Maybe you can... ?)
- name: Run danger
if: contains(github.event.pull_request.head.repo.clone_url, github.repository)
- name: Run test
run: |
bundle exec danger
rake test
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 9b3b0d1

Please sign in to comment.