-
-
Notifications
You must be signed in to change notification settings - Fork 3
142 lines (130 loc) · 3.98 KB
/
struct-generate.yaml
File metadata and controls
142 lines (130 loc) · 3.98 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: struct-generate
on:
workflow_call:
inputs:
struct_file:
description: 'Path to the StructKit file'
type: string
required: false
default: '.struct.yaml'
output_dir:
description: 'Path to the output directory'
type: string
required: false
default: '.'
args:
description: 'Additional arguments to pass to StructKit'
type: string
required: false
default: ''
pr_title:
description: 'Title of the PR'
type: string
required: false
default: 'Run StructKit generate on repository'
pr_body:
description: 'Body of the PR'
type: string
required: false
default: 'This PR was automatically generated by the StructKit action.'
pr_assignees:
description: 'Assignees of the PR'
type: string
required: false
default: ''
pr_base:
description: 'Base branch of the PR'
type: string
required: false
default: 'main'
runs_on:
description: 'Runner to use'
type: string
required: false
default: 'ubuntu-latest'
custom_structure_repository:
description: 'Path to the custom structures repository'
type: string
required: false
default: ''
custom_structure_path:
description: 'Path to the custom structures directory'
type: string
required: false
default: 'structures'
version:
description: 'StructKit version to install'
type: string
required: false
default: 'main'
secrets:
token:
description: 'GitHub token'
required: true
jobs:
run:
runs-on: ${{ inputs.runs_on }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install StructKit (latest)
if: ${{ inputs.version == 'main' }}
run: |
pip install git+https://github.com/httpdss/structkit.git
structkit -h
- name: Install StructKit (specific version)
if: ${{ inputs.version != 'main' }}
run: |
pip install structkit==${{ inputs.version }}
structkit -h
- name: Install custom structures
if: ${{ inputs.custom_structure_repository != '' }}
uses: actions/checkout@v5
with:
repository: ${{ inputs.custom_structure_repository }}
token: ${{ secrets.token }}
path: ./custom-structures
fetch-depth: 1
- name: Run StructKit
env:
GITHUB_TOKEN: ${{ secrets.token }}
run: |
if [ -d ./custom-structures ]; then
structkit list \
-s ./custom-structures/${{ inputs.custom_structure_path }}
structkit generate \
--non-interactive \
-s ./custom-structures/${{ inputs.custom_structure_path }} \
${{ inputs.args }} \
${{ inputs.struct_file }} \
${{ inputs.output_dir }}
else
structkit list
structkit generate \
--non-interactive \
${{ inputs.args }} \
${{ inputs.struct_file }} \
${{ inputs.output_dir }}
fi
- name: Remove custom-structures before PR generation
run: |
if [ -d ./custom-structures ]; then
rm -rf ./custom-structures
fi
- name: Generate PR with changes
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.token }}
commit-message: ${{ inputs.pr_title }}
title: ${{ inputs.pr_title }}
body: |
${{ inputs.pr_body }}
base: ${{ inputs.pr_base }}
assignees: ${{ inputs.pr_assignees }}
branch: repository-dispatch/update-${{ github.run_id }}
labels: |
automated-pr