From 9bef1dc0a66e5eda4c3209ab0e59f7061dc48581 Mon Sep 17 00:00:00 2001 From: Bradley Bain Date: Tue, 20 Aug 2019 13:12:17 -0500 Subject: [PATCH 1/4] Create .github/workflows/capistrano.yml Use [GitHub Actions!](https://help.github.com/en/articles/about-actions) --- .github/workflows/capistrano.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/capistrano.yml diff --git a/.github/workflows/capistrano.yml b/.github/workflows/capistrano.yml new file mode 100644 index 00000000..54123a5e --- /dev/null +++ b/.github/workflows/capistrano.yml @@ -0,0 +1,23 @@ +name: Ruby + +on: + push: + - release/* + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up Ruby 2.3.3 + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.3.3 + - name: Install gem dependencies + run: | + gem install bundler + bundle install --jobs 4 --retry 3 + - name: Deploy to production + run: bundle exec cap production deploy From 8375674ee1e8970ee57f9228cdb576883d5947a7 Mon Sep 17 00:00:00 2001 From: Bradley Bain Date: Tue, 20 Aug 2019 13:16:42 -0500 Subject: [PATCH 2/4] Update capistrano.yml --- .github/workflows/capistrano.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/capistrano.yml b/.github/workflows/capistrano.yml index 54123a5e..303cf4f5 100644 --- a/.github/workflows/capistrano.yml +++ b/.github/workflows/capistrano.yml @@ -2,6 +2,7 @@ name: Ruby on: push: + branches: - release/* jobs: From 652b385438a5dce2e2562edec0939e068362c868 Mon Sep 17 00:00:00 2001 From: Bradley Bain Date: Tue, 20 Aug 2019 15:05:29 -0500 Subject: [PATCH 3/4] Avoid permissions issues when multiple users deploy the same app via capistrano --- Capfile | 2 ++ config/deploy.rb | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/Capfile b/Capfile index ea4138e7..dc0d301a 100644 --- a/Capfile +++ b/Capfile @@ -24,11 +24,13 @@ require "capistrano/rvm" require "capistrano/rails" require "capistrano/puma" require "capistrano/yarn" +require "byebug" install_plugin Capistrano::Puma # Default puma tasks # Execute rake tasks remotely require "capistrano/rake" +require "capistrano/yarn" # Load custom tasks from `lib/capistrano/tasks` if you have any defined Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } diff --git a/config/deploy.rb b/config/deploy.rb index 68cbf1dc..b43784f9 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -17,6 +17,13 @@ ask :password, "Password for peninsula.pomona.edu", echo: false # Default branch is :master +set :git_wrapper_path, lambda { + # Try to avoid permissions issues when multiple users deploy the same app + # by using different file names in the same dir for each deployer and stage. + suffix = %i(application stage user).map { |key| fetch(key).to_s }.join("-") + + "#{fetch(:tmp_dir)}/git-ssh-#{suffix}.sh" +} # ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp # Set default rails environment to production (may be overridden in production/staging configs) From 206e7f7d0933284e753738fb6d40733807fa60f6 Mon Sep 17 00:00:00 2001 From: Bradley Bain Date: Tue, 20 Aug 2019 15:39:20 -0500 Subject: [PATCH 4/4] Read from rails credentials if applicable --- config/credentials.yml.enc | 2 +- config/deploy.rb | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index 3a34d8ca..e1939eb6 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -xFhuE2+oVr7P+N6Nj4fj3FRC9a+ywCn8Qu3eMPCJyYhb+zO06xRDVyed7JZNv95rY4fkWyU/LRKK4YrDwOdhuPpl/u7OqHurofcUhybrcS0pHnyUrY4N3s0fDUjeTgIMcTwmDIF+Mq2bubNjr997Pmv/7puIlx6GwbdISELFlfntNHnY0rmN/4QXhZZqEQReqnDjLEX6gCdJ4qBH2RP7ikeouiGGFK3mXJwZXyU9RE52vA4m9LBZUuYfX9JOEPShWDZlNTPY1473+R25SclnTVIDtmRf3pitrZ/67D71VJaSDCPhqQE6KifqqZTggJDJvrWA2lRn2lh07ZmcUBv8H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RqTozpJhC7fThYO+8ZyHMW+H60ziQz7dDZNOPKTh7O9zZfcECLRPWxJ71RcTku098Yb1oj0r5JqeCfsQGLmV2zNE8F2i5Yit2y19XMZj0lIGCbtXmCbldJxNLVK9LCwBLVLFpeyeP5WRccl7ZSrwlzPbxAvlrhNXVT2fgGzl/eWMKmYES8j3fUPzxapAPNHXdJVc55n9gWFGhrLflUzVLcJUPHDYBaZUrUtmwbzY8YsBdMOTSIq68Iw6g/G1Q7RMJKsKJ8+H2qIvZYgJQJ8p1xQNw5suwHs2CqaAlu++A++D4SEfgQEXR9zN1vrYt3Ys0PFch5w9TrcodoLei0DGuFM2avl9G5b6PGEvswjrlGMmTEKskxy1gJStF4EYb23wcRKrie2hjt6eVYnXfTPKyhILqHgPyVQigZxWWLGfS1o7zyzpBzK9/FNeQih7mmBh4jLb2vfxm52UTEDOToQUl/nQHE3H7Um9UVX1SDC6/qvFfWLuvNCcmCYHcN5W9CUhebdfrB8L6zULwjEvjJfokTg3uh4uca/LQRRClvzCbwvXQsEjI70nUVddghTAWnh24H+UOnq9OunXMgPdvRgcL9qMKZrg4ehmqwy0cCDNcVvhKPIfIT28umn6QJBA9N/4plTMdRAz1l7zJ9EelNTQzIjAm+yaayjht4+mg0cYYD2PvirqBg4C9qYGmmjBNVuVIdNyw==--eF88EwAe/nvinaDr--6GErDxjXfBknBmdo0wgnQA== \ No newline at end of file diff --git a/config/deploy.rb b/config/deploy.rb index b43784f9..ab4938ad 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -13,10 +13,16 @@ set :repo_url, "https://github.com/aspc/aspc-website.git" # SSH Authentication -ask :user, "Username for peninsula.pomona.edu" -ask :password, "Password for peninsula.pomona.edu", echo: false - -# Default branch is :master +ssh_credentials = YAML.load(`rails credentials:show`).dig("capistrano", "ssh") +if ssh_credentials["user"] && ssh_credentials["password"] + set :user, ssh_credentials["user"] + set :password, ssh_credentials["password"] +else + ask :user, "Username for peninsula.pomona.edu" + ask :password, "Password for peninsula.pomona.edu", echo: false +end + +# Git permissions set :git_wrapper_path, lambda { # Try to avoid permissions issues when multiple users deploy the same app # by using different file names in the same dir for each deployer and stage. @@ -24,7 +30,6 @@ "#{fetch(:tmp_dir)}/git-ssh-#{suffix}.sh" } -# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp # Set default rails environment to production (may be overridden in production/staging configs) set :rails_env, :production