This commit is contained in:
2024-07-16 18:19:12 -05:00
parent fa983add62
commit 0716974261
2 changed files with 34 additions and 1 deletions

26
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,26 @@
variables:
script:
description: "Which script to run?"
value: ""
- ""
- "CreateRepos"
ProjectName:
description: "Name of the Project (For CreateRepos)"
GITLAB_TOKEN:
description: "Gitlab Token"
GITHUB_TOKEN:
description: "Github token"
GITEA_TOKEN:
description: "Gitea Token"
CreateRepos:
image: mcr.microsoft.com/powershell:latest
script:
- pwsh -f ./scripts/gitlab-mirror.ps1 -ProjectName $ProjectName -GITLAB_TOKEN $GITLAB_TOKEN -GITHUB_TOKEN $GITHUB_TOKEN -GITEA_TOKEN $GITEA_TOKEN
rules:
- if: $script == "CreateRepos"
- when: never

View File

@@ -1,4 +1,9 @@
$ProjectName = Read-Host "What is the name of the project?" param(
$ProjectName,
$GITLAB_TOKEN,
$GITHUB_TOKEN,
$GITEA_TOKEN
)
$gitlabDefaultHeaders = @{ $gitlabDefaultHeaders = @{
"PRIVATE-TOKEN" = $GITLAB_TOKEN "PRIVATE-TOKEN" = $GITLAB_TOKEN
@@ -7,6 +12,7 @@ $gitlabDefaultHeaders = @{
$gitlabBaseURI = "https://gitlab.com/api/v4" $gitlabBaseURI = "https://gitlab.com/api/v4"
#Create Gitlab Repo #Create Gitlab Repo
Write-Host "Creating Gitlab Repo"
$irm = @{ $irm = @{
uri = "$gitlabBaseURI/projects" uri = "$gitlabBaseURI/projects"
headers = $gitlabDefaultHeaders headers = $gitlabDefaultHeaders
@@ -21,6 +27,7 @@ $irm = @{
$gitlabProject = Invoke-RestMethod @irm $gitlabProject = Invoke-RestMethod @irm
#Create repos in github/gitea and add to gitlab mirror #Create repos in github/gitea and add to gitlab mirror
Write-Host "Creating Github and Gitea Repos"
$repos = @( $repos = @(
@{ @{
DefaultHeaders = @{ DefaultHeaders = @{