version: 2.1 orbs: ruby: circleci/ruby@2.1.0 slack: circleci/slack@3.4.2 executors: base: docker: - image: cimg/ruby:3.1.0 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: # ref:https://circleci.com/docs/ja/github-integration/#create-a-github-deploy-key - add_ssh_keys: fingerprints: - "48:2e:41:d0:6a:c5:f8:37:49:9e:3a:00:f8:74:5c:7b" - run: name: Avoid hosts unknown for github command: | ssh-keyscan github.com >> ~/.ssh/known_hosts - run: name: Deploy RubyGems command: | mkdir -p ~/.gem touch ~/.gem/credentials chmod 0600 ~/.gem/credentials printf -- "---\n:rubygems_api_key: ${RUBYGEMS_AUTH_TOKEN}\n" > ~/.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