name: "<%=@pipeline_name %>"
on:
  <%@on_nodes.each do |node| %>
  <%if node.name.to_s.include?("on-push") && node.input_values.present? %>
  push:
    <% node.input_values.each_key do |key| %>
    <%=key %>:
      <% if node.input_values[key].blank? %>
      - '*'
      <% else %>
        <% node.input_values[key].to_s.split(",").each do |val| %>
      - <%=val %>
        <% end %>
      <% end %>
    <% end %>
    paths-ignore:
      - '.gitea/workflows/**'
      - '.github/workflows/**'
  <% end %>
  <%if node.name.to_s.include?("on-pull_request") %>
  pull_request:
  <% end %>
  <%if node.name.to_s.include?("on-fork") %>
  fork:
  <% end %>
  <%if node.name.to_s.include?("on-schedule") && node.input_values.present? %>
  schedule:
    <% node.input_values.each_key do |key| %>
    - <%=key %>: "<%=node.input_values[key] %>"
    <% end %>
  <% end %>
  <% end %>

jobs:
<%@job_nodes.each_with_index do |job,index| %>
  <%=job.node_id %>:
    name: "<%=job.label || job.name %>[<%=job.node_id %>]"
    # 运行环境，这里就是上面定义的多个 os
    runs-on: 'ubuntu-latest'
    <% if index >0 %>
    needs: <%=job.parent_node_id %>
    <% end %>
    steps:
    <%job.sub_nodes.each do |node| %>
      - name: "<%=node.label || node.name %>[<%=node.node_id %>]"
            <% if node.name !="shell" %>
        uses: <%=node.full_name %>
            <% end %>
            <%if node.input_values.present? %>
        with:
          <% node.input_values.each_key do |key| %>
          <%=key %>: '<%=node.input_values[key] %>'
          <%end %>
        <%end %>
        <%if node.run_values.present? %>
          <% node.run_values.each_key do |key| %>
        <%=key %>: |
          <%=node.run_values[key] %>
          <%end %>
        <%end %>
      <% end %>
<%end %>
