version: 2.1 orbs: ruby: circleci/ruby@1.1.2 slack: circleci/slack@3.4.2 executors: base: docker: - image: cimg/ruby:2.6.6 auth: username: dodonki1223 password: $DOCKERHUB_PASSWORD environment: # Bundlerのパス設定が書き換えられ`vendor/bundle`ではなくて`/usr/local/bundle`を参照してしまい`bundle exec`でエラーになる # Bundlerのconfigファイル(pathの設定がされたもの)をworkspaceで永続化し`vendor/bundle`を参照するようにするための設定 BUNDLE_APP_CONFIG: .bundle # ref: https://circleci.com/docs/2.0/faq/#how-can-i-set-the-timezone-in-docker-images TZ: "Asia/Tokyo" working_directory: ~/dodonki1223/qiita_trend commands: save-workspace: steps: - persist_to_workspace: # working_directory からの相対パスか絶対パスを指定します root: . paths: . using-workspace: steps: - attach_workspace: # working_directory からの相対パスか絶対パスを指定します at: . collect-reports: steps: - store_artifacts: # カバレッジの結果をcoverage-resultsディレクトリに吐き出す path: coverage destination: coverage-results create-document: steps: - run: name: Create document command: | bundle exec yard - store_artifacts: # ドキュメントの結果をyard-resultsディレクトリに吐き出す path: ./doc destination: yard-results deploy-rubygems: steps: # https://discuss.circleci.com/t/the-authenticity-of-github-host-cant-be-stablished/33133 と同じ現象で job が進まなくなるので以下の記事を参考に実装 # ref:https://circleci.com/docs/ja/2.0/gh-bb-integration/#ssh-%E3%83%9B%E3%82%B9%E3%83%88%E3%81%AE%E4%BF%A1%E9%A0%BC%E6%80%A7%E3%81%AE%E7%A2%BA%E7%AB%8B - run: name: Avoid hosts unknown for github command: | mkdir -p ~/.ssh echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== ' >> ~/.ssh/known_hosts - run: name: Deploy RubyGems command: | curl -u dodonki1223:$RUBYGEMS_PASSWORD https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials chmod 0600 ~/.gem/credentials git config user.name dodonki1223 git config user.email $RUBYGEMS_EMAIL bundle exec rake build bundle exec rake release deploy-notification: steps: - slack/status: success_message: ':circleci-pass: RubyGemsにデプロイが完了しました\n:github_octocat: User: $CIRCLE_USERNAME' failure_message: ':circleci-fail: RubyGemsにデプロイが失敗しました\n:github_octocat: User: $CIRCLE_USERNAME' jobs: setup: executor: base steps: - checkout - ruby/install-deps - save-workspace lint: executor: base steps: - using-workspace - ruby/install-deps - ruby/rubocop-check test: executor: base steps: - using-workspace - ruby/install-deps - ruby/rspec-test: out-path: 'test_results/rspec/' - collect-reports document: executor: base steps: - using-workspace - ruby/install-deps - create-document deploy: executor: base steps: - using-workspace - ruby/install-deps - deploy-rubygems - deploy-notification workflows: version: 2.1 main: jobs: - setup - lint: requires: - setup - test: requires: - setup - document: requires: - setup - slack/approval-notification: message: ':circleci-pass: RubyGemsへのデプロイ準備が整っています\n:github_octocat: User: $CIRCLE_USERNAME\nデプロイを実行する場合は *Approve* を押してください' requires: - lint - test filters: branches: only: master - approval-job: type: approval requires: - slack/approval-notification - deploy: requires: - approval-job filters: branches: only: master # 定期でテストを実行する # ref:https://circleci.com/docs/ja/2.0/triggers/ nightly: triggers: - schedule: cron: "0 22 * * *" # UTCで記述 filters: branches: only: - master jobs: - setup - test: requires: - setup