<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Test and deploy a Ruby application with GitLab CI/CD > 原文:[https://docs.gitlab.com/ee/ci/examples/test-and-deploy-ruby-application-to-heroku.html](https://docs.gitlab.com/ee/ci/examples/test-and-deploy-ruby-application-to-heroku.html) * [Configure the project](#configure-the-project) * [Store API keys](#store-api-keys) * [Create Heroku application](#create-heroku-application) * [Create Runner](#create-runner) # Test and deploy a Ruby application with GitLab CI/CD[](#test-and-deploy-a-ruby-application-with-gitlab-cicd "Permalink") 該示例將指導您如何在 Ruby on Rails 應用程序中運行測試,以及如何將其自動部署為 Heroku 應用程序. 您還可以查看或派生完整的[示例源,](https://gitlab.com/ayufan/ruby-getting-started)并查看其過去[CI 作業](https://gitlab.com/ayufan/ruby-getting-started/-/jobs?scope=finished)的日志. ## Configure the project[](#configure-the-project "Permalink") 這是此項目的`.gitlab-ci.yml`文件的外觀: ``` test: stage: test script: - apt-get update -qy - apt-get install -y nodejs - bundle install --path /cache - bundle exec rake db:create RAILS_ENV=test - bundle exec rake test staging: stage: deploy script: - gem install dpl - dpl --provider=heroku --app=gitlab-ci-ruby-test-staging --api-key=$HEROKU_STAGING_API_KEY only: - master production: stage: deploy script: - gem install dpl - dpl --provider=heroku --app=gitlab-ci-ruby-test-prod --api-key=$HEROKU_PRODUCTION_API_KEY only: - tags ``` 這個項目有三個工作: * `test` -用于測試 Rails 應用程序. * `staging` -用于每次推送到`master`分支時自動部署登臺環境. * `production` -用于為每個創建的標簽自動部署生產環境. ## Store API keys[](#store-api-keys "Permalink") 您需要在項目的**設置> CI / CD>環境變量中**創建兩個**變量** : * `HEROKU_STAGING_API_KEY` -Heroku API 密鑰,用于部署登臺應用程序. * `HEROKU_PRODUCTION_API_KEY` -Heroku API 密鑰,用于部署生產應用程序. Find your Heroku API key in [Manage Account](https://dashboard.heroku.com/account). ## Create Heroku application[](#create-heroku-application "Permalink") 對于每個環境,您都需要創建一個新的 Heroku 應用程序. 您可以通過[Heroku 儀表板](https://dashboard.heroku.com/)執行此操作. ## Create Runner[](#create-runner "Permalink") 首先安裝[Docker Engine](https://s0docs0docker0com.icopy.site/installation/) . 要構建此項目,您還需要安裝[GitLab Runner](https://docs.gitlab.com/runner/) . 您可以使用`gitlab.com`上的公共跑步者或注冊自己的跑步者. 首先創建模板配置文件以通過復雜的配置: ``` cat > /tmp/test-config.template.toml << EOF [[runners]] [runners.docker] [[runners.docker.services]] name = "postgres:latest" EOF ``` 最后,注冊運行器,并傳遞新創建的模板配置文件: ``` gitlab-runner register \ --non-interactive \ --url "https://gitlab.com/" \ --registration-token "PROJECT_REGISTRATION_TOKEN" \ --description "ruby:2.6" \ --executor "docker" \ --template-config /tmp/test-config.template.toml \ --docker-image ruby:2.6 ``` 使用上面的命令,您將創建一個使用[`ruby:2.6`](https://hub.docker.com/_/ruby)圖像并使用[PostgreSQL](https://hub.docker.com/_/postgres)數據庫的 Runner. 要訪問 PostgreSQL 數據庫,請以沒有密碼的用戶`postgres`身份連接到`host: postgres` .
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看