-
-
Notifications
You must be signed in to change notification settings - Fork 64
144 lines (123 loc) · 4.72 KB
/
generate-gh-feature.yml
File metadata and controls
144 lines (123 loc) · 4.72 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
143
144
name: Generate Feature from gh-release Template
on:
workflow_dispatch:
inputs:
ID:
description: 'Feature identifier (e.g., akamai-cli)'
required: true
type: string
Description:
description: 'Feature description'
required: true
type: string
Repository:
description: 'GitHub repository in format "owner/repo" (e.g., akamai/cli)'
required: true
type: string
BinaryNames:
description: 'Binary names (comma-separated if multiple)'
required: true
type: string
BinaryVersionCommands:
description: 'Version check commands (comma-separated if multiple)'
required: false
type: string
default: '--version'
BinaryNonLatestVersions:
description: 'Non-latest versions for testing (comma-separated if multiple)'
required: true
type: string
jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ secrets.ARCHIVE_TOKEN }}
- name: Check if feature already exists
run: |
if [ -d "src/${{ inputs.ID }}" ] || [ -d "test/${{ inputs.ID }}" ]; then
echo "❌ Feature '${{ inputs.ID }}' already exists!"
echo "Please use a different feature ID or remove the existing feature first."
exit 1
fi
echo "✅ Feature ID is available"
- name: Validate GitHub repository exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh api repos/${{ inputs.Repository }} > /dev/null 2>&1; then
echo "✅ Repository '${{ inputs.Repository }}' exists and is accessible"
else
echo "⚠️ Warning: Could not verify repository '${{ inputs.Repository }}'"
echo "The repository might be private, not exist, or you don't have access to it."
echo "Continuing with feature generation..."
fi
- name: Download boilerplate
run: |
wget -q https://github.com/gruntwork-io/boilerplate/releases/download/v0.10.1/boilerplate_linux_amd64
chmod +x boilerplate_linux_amd64
- name: Create vars.yml
run: |
cat > vars.yml << 'EOF'
ID: ${{ inputs.ID }}
Description: ${{ inputs.Description }}
Repository: ${{ inputs.Repository }}
BinaryNames: ${{ inputs.BinaryNames }}
BinaryVersionCommands: ${{ inputs.BinaryVersionCommands }}
BinaryNonLatestVersions: ${{ inputs.BinaryNonLatestVersions }}
EOF
echo "📝 Created vars.yml:"
cat vars.yml
- name: Create branch for new feature
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b feature/${{ inputs.ID }}-init
- name: Generate feature files
run: |
echo "🔧 Generating feature files from templates/gh-release..."
./boilerplate_linux_amd64 \
--template-url templates/gh-release/ \
--output-folder src/${{ inputs.ID }} \
--var-file vars.yml \
--non-interactive
- name: Generate test files
run: |
echo "🧪 Generating test files from templates/test..."
./boilerplate_linux_amd64 \
--template-url templates/test/ \
--output-folder test/${{ inputs.ID }} \
--var-file vars.yml \
--non-interactive
- name: Commit changes
run: |
git add src/ test/
git commit -m "feat(${{ inputs.ID }}): init
Generated using boilerplate templates."
- name: Push changes
run: git push origin feature/${{ inputs.ID }}-init
- name: Create PR body file
run: |
cat > pr_body.md << 'EOF'
## New Feature: `${{ inputs.ID }}`
**Description:** ${{ inputs.Description }}
**Repository:** [${{ inputs.Repository }}](https://github.com/${{ inputs.Repository }})
**Binaries:** `${{ inputs.BinaryNames }}`
**Version Commands:** `${{ inputs.BinaryVersionCommands }}`
**Test Versions:** `${{ inputs.BinaryNonLatestVersions }}`
---
This PR was automatically generated using the boilerplate templates.
EOF
echo "📝 PR body content:"
cat pr_body.md
- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.ARCHIVE_TOKEN }}
run: |
gh pr create \
--title "feat(${{ inputs.ID }}): init" \
--body-file pr_body.md \
--base main \
--head feature/${{ inputs.ID }}-init