BigW Consortium Gitlab

gitlab_ci_yml_template.rb 940 Bytes
Newer Older
1 2
module Gitlab
  module Template
3
    class GitlabCiYmlTemplate < BaseTemplate
4 5 6 7 8
      def content
        explanation = "# This file is a template, and might need editing before it works on your project."
        [explanation, super].join("\n")
      end

9 10 11 12 13 14 15
      class << self
        def extension
          '.gitlab-ci.yml'
        end

        def categories
          {
16 17
            'General' => '',
            'Pages' => 'Pages',
18
            'Auto deploy' => 'autodeploy'
19 20 21 22 23 24
          }
        end

        def base_dir
          Rails.root.join('vendor/gitlab-ci-yml')
        end
25 26 27 28

        def finder(project = nil)
          Gitlab::Template::Finders::GlobalTemplateFinder.new(self.base_dir, self.extension, self.categories)
        end
29 30

        def dropdown_names(context)
31
          categories = context == 'autodeploy' ? ['Auto deploy'] : ['General', 'Pages']
32 33
          super().slice(*categories)
        end
34 35 36 37
      end
    end
  end
end