summaryrefslogtreecommitdiff
path: root/lib/gitlab/template/gitlab_ci_yml_template.rb
blob: fbefb5f7f0ebe3041b6276c078bf39340f1cd3e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

module Gitlab
  module Template
    class GitlabCiYmlTemplate < BaseTemplate
      def content
        explanation = "# This file is a template, and might need editing before it works on your project."
        [explanation, super].join("\n")
      end

      class << self
        def extension
          '.gitlab-ci.yml'
        end

        def categories
          {
            'General' => '',
            'Pages' => 'Pages',
            'Auto deploy' => 'autodeploy'
          }
        end

        def base_dir
          Rails.root.join('lib/gitlab/ci/templates')
        end

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

        def dropdown_names(context)
          categories = context == 'autodeploy' ? ['Auto deploy'] : %w(General Pages)
          super().slice(*categories)
        end
      end
    end
  end
end