From 9b3b0d12895b9da7554a5d033b79f6382ca26d95 Mon Sep 17 00:00:00 2001 From: Yusuke Hosonuma Date: Mon, 17 Feb 2020 05:46:44 +0900 Subject: [PATCH] CI: run rspec in GitHub Actions --- .github/workflows/danger.yml | 51 ++++++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 27 +++---------------- 2 files changed, 55 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/danger.yml diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml new file mode 100644 index 0000000..be6de12 --- /dev/null +++ b/.github/workflows/danger.yml @@ -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 '2990285+YusukeHosonuma@users.noreply.github.com' + 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 }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index be6de12..7c21ff8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,6 @@ -name: Run danger +name: Test -on: [pull_request] +on: [push] jobs: build: @@ -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 '2990285+YusukeHosonuma@users.noreply.github.com' - 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 }}