git - 如何使用 Capistrano v3 将发布标记到 Git

标签 git ubuntu github tags capistrano3

我正在使用 Capistrano v3,我正在尝试标记部署并将它们推送到 github。

到目前为止,我有:

task :tag do 
    on roles (:app) do
      puts "\x1B[35m Tagging deployment... \x1B[0m"

      timestamp = Time.now.strftime("%Y_%m_%d_%H_%M_%S")
      tag_name = "#{fetch(:stage)}_#{timestamp}"
      puts "\x1B[35m tag name... \x1B[0m" + tag_name
      execute "cd #{repo_path} && git tag #{tag_name} && git push origin --tags"

      puts "\x1B[35m Done. Deployment tagged as #{fetch(:tag_name)} \x1B[0m"
    end
  end

事情是repo_path是一个镜像仓库,当然我不能执行或使用 --tags因为它会引发错误。

关于如何完成这个非常简单的任务的任何想法?

最佳答案

我找到了解决方案。

我基本上做了以下事情:

desc "Tag deployed release"
    task :tag do
    run_locally do
      timestamp = Time.now.strftime("%Y_%m_%d_%H_%M_%S")
      tag_name = "#{fetch(:stage)}_#{timestamp}"
      latest_revision = fetch(:current_revision)
      strategy.git "tag -f #{tag_name} #{latest_revision}"
      strategy.git "push -f --tags"
      info "[cap-deploy-tagger] Tagged #{latest_revision} with #{tag_name}"
    end
  end

after :cleanup, 'deploy:tag'

这是完全有道理的。我在本地标记部署,而不是直接在服务器上进行:)

关于git - 如何使用 Capistrano v3 将发布标记到 Git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25773313/

相关文章:

python - pip3 的 PermissionError

github - 通过 API 在 GitHub 存储库中查找最旧的提交

github - 如何从 github 中删除我的公钥?

git - 将 Github Git 存储库迁移到 Azure DevOps TFVC

git - 从私有(private)存储库获取依赖项的正确方法

git - Github 使用的 diff 算法是什么?

ruby-on-rails - rails : FATAL: Password Authentication Failed For User

git - 为什么 "Compare with Unmodified"在 Visual Studio 2017 中不起作用?

Git 提交所有文件

ubuntu - ubuntu 中的 intellij IDEA 14 非常慢