Skip to content

Commit 0211eef

Browse files
committed
Add New Repository Setup workflow
1 parent 1b0133d commit 0211eef

1 file changed

Lines changed: 292 additions & 0 deletions

File tree

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
name: New Repository Setup
2+
3+
on:
4+
create: # Triggered when a branch or tag is created
5+
workflow_dispatch:
6+
inputs:
7+
setup_type:
8+
description: 'Type of setup to perform'
9+
required: true
10+
default: 'full'
11+
type: choice
12+
options:
13+
- full
14+
- minimal
15+
- documentation-only
16+
17+
jobs:
18+
setup-new-repo:
19+
name: Initialize New Repository
20+
runs-on: ubuntu-latest
21+
# Only run on main/master branch creation or manual trigger
22+
if: |
23+
(github.event_name == 'create' && github.event.ref_type == 'branch' &&
24+
(github.event.ref == 'main' || github.event.ref == 'master')) ||
25+
github.event_name == 'workflow_dispatch'
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v3
30+
with:
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Check existing files
34+
id: check-files
35+
run: |
36+
echo "=== Checking Existing Files ==="
37+
38+
# Check what files already exist
39+
has_readme="false"
40+
has_license="false"
41+
has_gitignore="false"
42+
has_contributing="false"
43+
44+
[ -f "README.md" ] || [ -f "README" ] || [ -f "readme.md" ] && has_readme="true"
45+
[ -f "LICENSE" ] || [ -f "LICENSE.md" ] || [ -f "LICENSE.txt" ] && has_license="true"
46+
[ -f ".gitignore" ] && has_gitignore="true"
47+
[ -f "CONTRIBUTING.md" ] || [ -f "contributing.md" ] && has_contributing="true"
48+
49+
echo "has_readme=$has_readme" >> $GITHUB_OUTPUT
50+
echo "has_license=$has_license" >> $GITHUB_OUTPUT
51+
echo "has_gitignore=$has_gitignore" >> $GITHUB_OUTPUT
52+
echo "has_contributing=$has_contributing" >> $GITHUB_OUTPUT
53+
54+
echo "README exists: $has_readme"
55+
echo "LICENSE exists: $has_license"
56+
echo ".gitignore exists: $has_gitignore"
57+
echo "CONTRIBUTING exists: $has_contributing"
58+
59+
- name: Create README
60+
if: steps.check-files.outputs.has_readme == 'false'
61+
run: |
62+
cat > README.md << 'EOF'
63+
# ${{ github.event.repository.name }}
64+
65+
> ${{ github.event.repository.description || 'A new repository in the ' + github.repository_owner + ' organization' }}
66+
67+
## Getting Started
68+
69+
This repository was automatically initialized. Please update this README with:
70+
71+
- [ ] Project description and purpose
72+
- [ ] Installation instructions
73+
- [ ] Usage examples
74+
- [ ] Contributing guidelines
75+
- [ ] License information
76+
77+
## Quick Start
78+
79+
```bash
80+
# Clone the repository
81+
git clone https://github.com/${{ github.repository }}.git
82+
cd ${{ github.event.repository.name }}
83+
84+
# Add your setup instructions here
85+
```
86+
87+
## Contributing
88+
89+
Contributions are welcome! Please feel free to submit a Pull Request.
90+
91+
## License
92+
93+
This project needs a license. See [Choose a License](https://choosealicense.com/) for help selecting one.
94+
95+
---
96+
97+
**${{ github.repository_owner }}** - Building quality software
98+
EOF
99+
100+
echo "✅ Created README.md"
101+
102+
- name: Create .gitignore
103+
if: steps.check-files.outputs.has_gitignore == 'false'
104+
run: |
105+
# Detect primary language and create appropriate .gitignore
106+
107+
# Default .gitignore
108+
cat > .gitignore << 'EOF'
109+
# Dependencies
110+
node_modules/
111+
vendor/
112+
venv/
113+
env/
114+
__pycache__/
115+
*.pyc
116+
117+
# Build outputs
118+
dist/
119+
build/
120+
out/
121+
target/
122+
*.exe
123+
*.dll
124+
*.so
125+
*.dylib
126+
127+
# IDE files
128+
.vscode/
129+
.idea/
130+
*.swp
131+
*.swo
132+
*~
133+
.project
134+
.classpath
135+
.settings/
136+
137+
# OS files
138+
.DS_Store
139+
Thumbs.db
140+
141+
# Environment files
142+
.env
143+
.env.local
144+
.env.*.local
145+
146+
# Logs
147+
logs/
148+
*.log
149+
npm-debug.log*
150+
yarn-debug.log*
151+
yarn-error.log*
152+
153+
# Testing
154+
coverage/
155+
.coverage
156+
htmlcov/
157+
.pytest_cache/
158+
.phpunit.result.cache
159+
160+
# Temporary files
161+
*.tmp
162+
*.temp
163+
.cache/
164+
EOF
165+
166+
echo "✅ Created .gitignore"
167+
168+
- name: Create MIT License
169+
if: steps.check-files.outputs.has_license == 'false' && github.event.inputs.setup_type != 'documentation-only'
170+
run: |
171+
year=$(date +%Y)
172+
cat > LICENSE << EOF
173+
MIT License
174+
175+
Copyright (c) $year ${{ github.repository_owner }}
176+
177+
Permission is hereby granted, free of charge, to any person obtaining a copy
178+
of this software and associated documentation files (the "Software"), to deal
179+
in the Software without restriction, including without limitation the rights
180+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
181+
copies of the Software, and to permit persons to whom the Software is
182+
furnished to do so, subject to the following conditions:
183+
184+
The above copyright notice and this permission notice shall be included in all
185+
copies or substantial portions of the Software.
186+
187+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
188+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
189+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
190+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
191+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
192+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
193+
SOFTWARE.
194+
EOF
195+
196+
echo "✅ Created LICENSE (MIT)"
197+
198+
- name: Create CONTRIBUTING.md
199+
if: steps.check-files.outputs.has_contributing == 'false' && github.event.inputs.setup_type == 'full'
200+
run: |
201+
cat > CONTRIBUTING.md << 'EOF'
202+
# Contributing to ${{ github.event.repository.name }}
203+
204+
Thank you for your interest in contributing! We welcome contributions from everyone.
205+
206+
## How to Contribute
207+
208+
1. Fork the repository
209+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
210+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
211+
4. Push to the branch (`git push origin feature/amazing-feature`)
212+
5. Open a Pull Request
213+
214+
## Code of Conduct
215+
216+
Please note that this project is released with a Contributor Code of Conduct.
217+
By participating in this project you agree to abide by its terms.
218+
219+
## Questions?
220+
221+
Feel free to open an issue with any questions or concerns.
222+
EOF
223+
224+
echo "✅ Created CONTRIBUTING.md"
225+
226+
- name: Commit changes
227+
run: |
228+
git config user.name "github-actions[bot]"
229+
git config user.email "github-actions[bot]@users.noreply.github.com"
230+
231+
git add .
232+
233+
if git diff --staged --quiet; then
234+
echo "No changes to commit"
235+
else
236+
git commit -m "🎉 Initialize repository with documentation
237+
238+
- Add README.md with setup instructions
239+
- Add .gitignore for common files
240+
- Add LICENSE (MIT)
241+
- Add CONTRIBUTING.md guidelines
242+
243+
[skip ci]"
244+
245+
git push
246+
echo "✅ Pushed initial documentation"
247+
fi
248+
249+
- name: Create initial issue
250+
if: github.event_name == 'create'
251+
run: |
252+
gh issue create \
253+
--title "🚀 Complete repository setup" \
254+
--body "Welcome to your new repository! Here's a checklist to get started:
255+
256+
## Repository Setup Checklist
257+
258+
### Documentation
259+
- [ ] Update README.md with project-specific information
260+
- [ ] Add detailed installation instructions
261+
- [ ] Include usage examples and API documentation
262+
- [ ] Add badges (build status, license, version)
263+
264+
### Configuration
265+
- [ ] Set repository description in Settings
266+
- [ ] Add relevant topics/tags (at least 3-5)
267+
- [ ] Configure branch protection rules
268+
- [ ] Set up GitHub Pages if needed
269+
270+
### Code Quality
271+
- [ ] Set up linting and formatting
272+
- [ ] Configure test framework
273+
- [ ] Add CI/CD workflows
274+
- [ ] Set up code coverage reporting
275+
276+
### Community
277+
- [ ] Choose appropriate license
278+
- [ ] Add CODE_OF_CONDUCT.md
279+
- [ ] Create issue templates
280+
- [ ] Set up pull request template
281+
282+
### Optional Enhancements
283+
- [ ] Add logo/banner to README
284+
- [ ] Create SECURITY.md for vulnerability reporting
285+
- [ ] Set up automated dependency updates
286+
- [ ] Configure release automation
287+
288+
---
289+
*This issue was automatically created to help you get started with your new repository.*" \
290+
--label "documentation" \
291+
--label "enhancement" \
292+
--label "good first issue"

0 commit comments

Comments
 (0)