Skip to content

Commit

Permalink
issue#1 DEVOPS-35
Browse files Browse the repository at this point in the history
  • Loading branch information
githubofkrishnadhas committed Jan 2, 2024
1 parent 156bbf7 commit 4bc9742
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/create_repository.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ on:
gitignore_template:
type: choice
options:
- " "
- AL
- Actionscript
- Ada
Expand All @@ -66,7 +67,7 @@ on:
- Coq
- CraftCMS
- D
- DM
- DM
- Dart
- Delphi
- Drupal
Expand Down Expand Up @@ -171,11 +172,17 @@ on:
- Zephir
required: false
description: 'Desired language or platform .gitignore template to apply. Use the name of the template'
auto_init:
required: false
description: 'Pass true to create an initial commit with empty README. Default: false'
type: boolean
license_template:
required: false
description: 'Choose license template'
type: choice
options:
- MIT
- " "
- AFL-3.0
- Apache-2.0
- Artistic-2.0
Expand All @@ -202,7 +209,6 @@ on:
- ISC
- LPPL-1.3c
- MS-PL
- MIT
- MPL-2.0
- OSL-3.0
- PostgreSQL
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Desired language or platform .gitignore template to apply. Use the name of the t
```
[gitignore-template](https://github.com/github/gitignore)

**if gitignore template and license templates are set as " " then they will not be addded to payload.**
27 changes: 26 additions & 1 deletion create_repository_in_github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,35 @@ HAS_WIKI=$8
GITIGNORE_TEMPLATE=$9
LICENSE_TEMPLATE=${10}

# Create the base payload without gitignore_template and license template
payload="{\"name\":\"$REPOSITORY_NAME\",\"description\":\"$REPOSITORY_DESCRIPTION\",\"homepage\":\"https://github.com/$ORGANIZATION/$REPOSITORY_NAME\",\"private\":$PRIVATE,\"has_issues\":$HAS_ISSUES,\"visibility\":\"$VISIBILITY\",\"has_projects\":$HAS_PROJECTS,\"has_wiki\":$HAS_WIKI"

# Check if gitignore template is provided, and if so, append it to the payload
if [ -n "$GITIGNORE_TEMPLATE" ] && [ "$GITIGNORE_TEMPLATE" != " " ]; then
payload="$payload,\"gitignore_template\":\"$GITIGNORE_TEMPLATE\""
fi

# Check if license template is provided, and if so, append it to the payload
if [ -n "$LICENSE_TEMPLATE" ] && [ "$LICENSE_TEMPLATE" != " " ]; then
payload="$payload,\"license_template\":\"$LICENSE_TEMPLATE\""
fi

# Close the payload
payload="$payload}"

# Send the request to create the repository
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/$ORGANIZATION/repos \
-d "{\"name\":\"$REPOSITORY_NAME\",\"description\":\"$REPOSITORY_DESCRIPTION\",\"homepage\":\"https://github.com/$ORGANIZATION/$REPOSITORY_NAME\",\"private\":$PRIVATE,\"has_issues\":$HAS_ISSUES,\"visibility\":\"$VISIBILITY\",\"has_projects\":$HAS_PROJECTS,\"has_wiki\":$HAS_WIKI,\"gitignore_template\":\"$GITIGNORE_TEMPLATE\",\"license_template\":\"$LICENSE_TEMPLATE\"}"
-d "$payload"

# curl -L \
# -X POST \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer $GH_TOKEN" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# https://api.github.com/orgs/$ORGANIZATION/repos \
# -d "{\"name\":\"$REPOSITORY_NAME\",\"description\":\"$REPOSITORY_DESCRIPTION\",\"homepage\":\"https://github.com/$ORGANIZATION/$REPOSITORY_NAME\",\"private\":$PRIVATE,\"has_issues\":$HAS_ISSUES,\"visibility\":\"$VISIBILITY\",\"has_projects\":$HAS_PROJECTS,\"has_wiki\":$HAS_WIKI,\"gitignore_template\":\"$GITIGNORE_TEMPLATE\",\"license_template\":\"$LICENSE_TEMPLATE\"}"

0 comments on commit 4bc9742

Please sign in to comment.