Skip to content

Commit 599150a

Browse files
DEVOPS-23 intiial commit automate gh repo creation
1 parent 196972e commit 599150a

File tree

2 files changed

+253
-0
lines changed

2 files changed

+253
-0
lines changed
Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
name: create-github-repository-using-github-workflow
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
organization:
6+
type: string
7+
default: 'devwithkrishna'
8+
description: 'The GitHub organization where the repository will be created.'
9+
required: true
10+
repository_name:
11+
type: string
12+
default: ''
13+
description: 'Enter the repository name'
14+
required: true
15+
repository_description:
16+
type: string
17+
required: false
18+
description: 'A short description of the repository.'
19+
private:
20+
type: boolean
21+
default: false
22+
description: 'Whether the repository is private.'
23+
visibility:
24+
type: choice
25+
options:
26+
- public
27+
- private
28+
required: true
29+
has_issues:
30+
type: boolean
31+
description: 'Either true to enable issues for this repository or false to disable them.'
32+
default: true
33+
has_projects:
34+
type: boolean
35+
default: true
36+
description: 'Either true to enable projects for this repository or false to disable them'
37+
has_wiki:
38+
type: boolean
39+
default: true
40+
description: 'Either true to enable the wiki for this repository or false to disable it.'
41+
gitignore_template:
42+
type: choice
43+
options:
44+
- AL
45+
- Actionscript
46+
- Ada
47+
- Agda
48+
- Android
49+
- AppEngine
50+
- AppceleratorTitanium
51+
- ArchLinuxPackages
52+
- Autotools
53+
- C++
54+
- C
55+
- CFWheels
56+
- CMake
57+
- CONTRIBUTING.md
58+
- CUDA
59+
- CakePHP
60+
- ChefCookbook
61+
- Clojure
62+
- CodeIgniter
63+
- CommonLisp
64+
- Composer
65+
- Concrete5
66+
- Coq
67+
- CraftCMS
68+
- D
69+
- DM
70+
- Dart
71+
- Delphi
72+
- Drupal
73+
- EPiServer
74+
- Eagle
75+
- Elisp
76+
- Elixir
77+
- Elm
78+
- Erlang
79+
- ExpressionEngine
80+
- ExtJs
81+
- Fancy
82+
- Finale
83+
- FlaxEngine
84+
- ForceDotCom
85+
- Fortran
86+
- FuelPHP
87+
- GWT
88+
- Gcov
89+
- GitBook
90+
- Go
91+
- Godot
92+
- Gradle
93+
- Grails
94+
- Haskell
95+
- IGORPro
96+
- Idris
97+
- JBoss
98+
- JENKINS_HOME
99+
- Java
100+
- Jekyll
101+
- Joomla
102+
- Julia
103+
- KiCad
104+
- Kohana
105+
- Kotlin
106+
- LabVIEW
107+
- Laravel
108+
- Leiningen
109+
- LemonStand
110+
- Lilypond
111+
- Lithium
112+
- Lua
113+
- Magento
114+
- Maven
115+
- Mercury
116+
- MetaProgrammingSystem
117+
- Nanoc
118+
- Nim
119+
- Node
120+
- OCaml
121+
- Objective-C
122+
- Opa
123+
- OpenCart
124+
- OracleForms
125+
- Packer
126+
- Perl
127+
- Phalcon
128+
- PlayFramework
129+
- Plone
130+
- Prestashop
131+
- Processing
132+
- PureScript
133+
- Python
134+
- Qooxdoo
135+
- Qt
136+
- R
137+
- ROS
138+
- Racket
139+
- Rails
140+
- Raku
141+
- RhodesRhomobile
142+
- Ruby
143+
- Rust
144+
- SCons
145+
- Sass
146+
- Scala
147+
- Scheme
148+
- Scrivener
149+
- Sdcc
150+
- SeamGen
151+
- SketchUp
152+
- Smalltalk
153+
- Stella
154+
- SugarCRM
155+
- Swift
156+
- Symfony
157+
- SymphonyCMS
158+
- TeX
159+
- Terraform
160+
- Textpattern
161+
- TurboGears2
162+
- TwinCAT3
163+
- Typo3
164+
- Unity
165+
- UnrealEngine
166+
- WordPress
167+
- Xojo
168+
- Yeoman
169+
- Yii
170+
- ZendFramework
171+
- Zephir
172+
required: false
173+
description: 'Desired language or platform .gitignore template to apply. Use the name of the template'
174+
license_template:
175+
required: false
176+
description: ''
177+
type: choice
178+
options:
179+
- Academic Free License v3.0
180+
- Apache license 2.0
181+
- Artistic license 2.0
182+
- Boost Software License 1.0
183+
- BSD 2-clause "Simplified" license
184+
- BSD 3-clause "New" or "Revised" license
185+
- BSD 3-clause Clear license
186+
- BSD 4-clause "Original" or "Old" license
187+
- BSD Zero-Clause license
188+
- Creative Commons license family CC
189+
- Creative Commons Zero v1.0 Universal
190+
- Creative Commons Attribution 4.0
191+
- Creative Commons Attribution ShareAlike 4.0
192+
- Do What The F*ck You Want To Public License
193+
- Educational Community License v2.0
194+
- Eclipse Public License 1.0
195+
- Eclipse Public License 2.0
196+
- European Union Public License 1.1
197+
- GNU Affero General Public License v3.0
198+
- GNU General Public License family
199+
- GNU General Public License v2.0
200+
- GNU General Public License v3.0
201+
- GNU Lesser General Public License family
202+
- GNU Lesser General Public License v2.1
203+
- GNU Lesser General Public License v3.0
204+
- ISC
205+
- LaTeX Project Public License v1.3c
206+
- Microsoft Public License
207+
- MIT
208+
- Mozilla Public License 2.0
209+
- Open Software License 3.0
210+
- PostgreSQL License
211+
- SIL Open Font License 1.1
212+
- University of Illinois/NCSA Open Source License
213+
- The Unlicense
214+
- zLib License
215+
env:
216+
ORGANIZATION: ${{ github.event.inputs.organization }}
217+
REPOSITORY_NAME: ${{ github.event.inputs.repository_name }}
218+
REPOSITORY_DESCRIPTION: ${{ github.event.inputs.repository_description }}
219+
PRIVATE: ${{ github.event.inputs.private }}
220+
VISIBILITY: ${{ github.event.inputs.visibility }}
221+
HAS_ISSUES: ${{ github.event.inputs.has_issues }}
222+
HAS_PROJECTS: ${{ github.event.inputs.has_projects }}
223+
HAS_WIKI: ${{ github.event.inputs.has_wiki }}
224+
GITIGNORE_TEMPLATE: ${{ github.event.inputs.gitignore_template }}
225+
LICENSE_TEMPLATE: ${{ github.event.inputs.license_template }}
226+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub token provided by secrets.GITHUB_TOKEN
227+
228+
jobs:
229+
github-repository-creation-using-github-workflow:
230+
runs-on: ubuntu-latest
231+
steps:
232+
- name: Checkout code
233+
uses: actions/checkout@v4
234+
- name: Listing the files
235+
run: ls -la
236+
- name: Execute the program
237+
run: |
238+
bash create_repository_in_github.sh
239+
240+
241+
242+

create_repository_in_github.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#! /bin/bash
2+
3+
#GH_TOKEN --> will be passed from workflow as env variable
4+
5+
curl -L \
6+
-X POST \
7+
-H "Accept: application/vnd.github+json" \
8+
-H "Authorization: Bearer $GH_TOKEN" \
9+
-H "X-GitHub-Api-Version: 2022-11-28" \
10+
https://api.github.com/orgs/$ORGANIZATION/repos \
11+
-d '{"name":$REPOSITORY_NAME,"description":$c,"homepage":"https://github.com/"$ORGANIZATION/$REPOSITORY_NAME","private":$VISIBILITY,"has_issues":$HAS_ISSUES,"visibility":$VISIBILITY,"has_projects":$HAS_PROJECTS,"has_wiki":$HAS_WIKI,"gitignore_template":$GITIGNORE_TEMPLATE,"license_template":$LICENSE_TEMPLATE}'

0 commit comments

Comments
 (0)