2023-11-12 00:06:19

This commit is contained in:
z17CX 2023-11-12 00:06:19 +00:00
parent 7276898955
commit c49ff0eb55
Signed by: z17cx
GPG key ID: 3F5F87C84EE943E4
7 changed files with 306 additions and 2 deletions

200
.github/workflows/mirror.yml vendored Normal file
View file

@ -0,0 +1,200 @@
name: 'Mirror'
on:
- push
env:
OWNER: '${{ github.repository_owner }}'
USER_AGENT: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0'
jobs:
# ------------------------------------------------------------------------------------------------------------------ #
# GitLab.
# ------------------------------------------------------------------------------------------------------------------ #
mirror_gitlab:
runs-on: ubuntu-latest
name: 'GitLab'
env:
DOMAIN: 'https://gitlab.com'
VERSION: 'v4'
NSID: '69852292'
steps:
- name: 'Get repository name'
shell: bash
run: |
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
- name: 'Create repository'
shell: bash
run: |
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
if [[ "${http}" -ne 200 ]]; then
curl -X POST \
-H 'Authorization: Bearer ${{ secrets.BOT_MIRROR_TOKEN_GITLAB }}' \
-H 'Content-Type: application/json' \
-A '${{ env.USER_AGENT }}' \
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/projects/' \
-d '{"name":"${{ env.REPO_NAME }}","path":"${{ env.REPO_NAME }}","namespace_id":"${{ env.NSID }}","visibility":"public"}'
fi
- name: 'Mirror repository'
uses: ghastore/github-mirror@main
with:
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_GITLAB }}'
# ------------------------------------------------------------------------------------------------------------------ #
# Codeberg.
# ------------------------------------------------------------------------------------------------------------------ #
mirror_codeberg:
runs-on: ubuntu-latest
name: 'Codeberg'
env:
DOMAIN: 'https://codeberg.org'
VERSION: 'v1'
steps:
- name: 'Get repository name'
shell: bash
run: |
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
- name: 'Create repository'
shell: bash
run: |
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
if [[ "${http}" -ne 200 ]]; then
curl -X POST \
-H 'Authorization: token ${{ secrets.BOT_MIRROR_TOKEN_CODEBERG }}' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-A '${{ env.USER_AGENT }}' \
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/orgs/${{ env.OWNER }}/repos' \
-d '{"name":"${{ env.REPO_NAME }}"}'
fi
- name: 'Mirror repository'
uses: ghastore/github-mirror@main
with:
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_CODEBERG }}'
# ------------------------------------------------------------------------------------------------------------------ #
# MosHub.
# ------------------------------------------------------------------------------------------------------------------ #
mirror_moshub:
runs-on: ubuntu-latest
name: 'MosHub'
env:
DOMAIN: 'https://hub.mos.ru'
VERSION: 'v4'
NSID: '38795'
steps:
- name: 'Get repository name'
shell: bash
run: |
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
- name: 'Create repository'
shell: bash
run: |
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
if [[ "${http}" -ne 200 ]]; then
curl -X POST \
-H 'Authorization: Bearer ${{ secrets.BOT_MIRROR_TOKEN_MOSHUB }}' \
-H 'Content-Type: application/json' \
-A '${{ env.USER_AGENT }}' \
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/projects/' \
-d '{"name":"${{ env.REPO_NAME }}","path":"${{ env.REPO_NAME }}","namespace_id":"${{ env.NSID }}","visibility":"public"}'
fi
- name: 'Mirror repository'
uses: ghastore/github-mirror@main
with:
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_MOSHUB }}'
# ------------------------------------------------------------------------------------------------------------------ #
# GIT.ORG.RU.
# ------------------------------------------------------------------------------------------------------------------ #
mirror_gitorgru:
runs-on: ubuntu-latest
name: 'GIT.ORG.RU'
env:
DOMAIN: 'https://git.org.ru'
VERSION: 'v1'
steps:
- name: 'Get repository name'
shell: bash
run: |
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
- name: 'Create repository'
shell: bash
run: |
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
if [[ "${http}" -ne 200 ]]; then
curl -X POST \
-H 'Authorization: token ${{ secrets.BOT_MIRROR_TOKEN_GITORGRU }}' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-A '${{ env.USER_AGENT }}' \
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/orgs/${{ env.OWNER }}/repos' \
-d '{"name":"${{ env.REPO_NAME }}"}'
fi
- name: 'Mirror repository'
uses: ghastore/github-mirror@main
with:
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_GITORGRU }}'
# ------------------------------------------------------------------------------------------------------------------ #
# Disroot.
# ------------------------------------------------------------------------------------------------------------------ #
mirror_disroot:
runs-on: ubuntu-latest
name: 'Disroot'
env:
DOMAIN: 'https://git.disroot.org'
VERSION: 'v1'
steps:
- name: 'Get repository name'
shell: bash
run: |
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
- name: 'Create repository'
shell: bash
run: |
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
if [[ "${http}" -ne 200 ]]; then
curl -X POST \
-H 'Authorization: token ${{ secrets.BOT_MIRROR_TOKEN_DISROOT }}' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-A '${{ env.USER_AGENT }}' \
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/orgs/${{ env.OWNER }}/repos' \
-d '{"name":"${{ env.REPO_NAME }}"}'
fi
- name: 'Mirror repository'
uses: ghastore/github-mirror@main
with:
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_DISROOT }}'

0
CHANGELOG.md Normal file
View file

14
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,14 @@
# Contributing
- Feedback, wishes and suggestions can be sent by email.
- Constructive criticism, bug descriptions and other reports are welcome.
- Email: [mail@ihub.to](mailto:mail@ihub.to).
## Sources
- [**GitHub**](https://github.com/pkgstore)
- [GitLab](https://gitlab.com/pkgstore) (MIRROR)
- [Codeberg](https://codeberg.org/pkgstore) (MIRROR)
- [Disroot](https://git.disroot.org/pkgstore) (MIRROR)
- [MosHub](https://hub.mos.ru/pkgstore) (MIRROR)
- [Git.Org.Ru](https://git.org.ru/pkgstore) (MIRROR)

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Package Store
Copyright (c) 2023 iHub.TO <https://ihub.to>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

19
PkgStore.cURL.psd1 Normal file
View file

@ -0,0 +1,19 @@
@{
RootModule = 'PkgStore.cURL.psm1'
ModuleVersion = '0.1.0'
GUID = '02d8b827-f39b-484c-8e8d-f7d6aa8e8915'
Author = 'Kitsune Solar'
CompanyName = 'iHub.TO'
Copyright = '(c) 2023 Kitsune Solar. All rights reserved.'
Description = 'PowerShell module for cURL.'
PowerShellVersion = '7.2'
RequiredModules = @('PkgStore.Kernel')
FunctionsToExport = @('Start-cURL')
PrivateData = @{
PSData = @{
Tags = @('pwsh', 'curl')
LicenseUri = 'https://github.com/pkgstore/pwsh-curl/blob/main/LICENSE'
ProjectUri = 'https://github.com/pkgstore/pwsh-curl'
}
}
}

51
PkgStore.cURL.psm1 Normal file
View file

@ -0,0 +1,51 @@
<#PSScriptInfo
.VERSION 0.1.0
.GUID 02d8b827-f39b-484c-8e8d-f7d6aa8e8915
.AUTHOR Kitsune Solar
.AUTHOREMAIL mail@kitsune.solar
.COMPANYNAME iHub.TO
.COPYRIGHT 2023 Kitsune Solar. All rights reserved.
.LICENSEURI https://github.com/pkgstore/pwsh-curl/blob/main/LICENSE
.PROJECTURI
#>
$cURL = @('curl.exe', 'curl-ca-bundle.crt', 'libcurl-x64.def', 'libcurl-x64.dll')
$cURLExe = @{LiteralPath = "${PSScriptRoot}"; Filter = "$($cURL[0])"; Recurse = $true; File = $true}
$cURLExe = ((Get-ChildItem @cURLExe) | Select-Object -First 1)
$NL = "$([Environment]::NewLine)"
function Start-cURL() {
<#
.SYNOPSIS
.DESCRIPTION
#>
Param(
[Parameter(Mandatory)][Alias('U')][string[]]$URLs
)
Test-cURL
$URLs | ForEach-Object {
# Composing a app command.
$Params = @( '-L', '-O', "${_}" )
# Running a app.
& "${cURLExe}" $Params
}
}
function Test-cURL {
# Getting 'curl.exe' directory.
$D_App = "$($cURLExe.DirectoryName)"
# Checking the location of files.
$cURL | ForEach-Object {
if (-not (Test-Data -T 'F' -P "${D_App}\${_}")) {
Write-Msg -T 'W' -A 'Stop' -M ("'${_}' not found!${NL}${NL}" +
"1. Download cURL from 'https://curl.se/windows/'.${NL}" +
"2. Extract all the contents of the archive into a directory '${PSScriptRoot}'.")
}
}
}

View file

@ -1 +1,21 @@
# pwsh-curl
# PowerShell cURL Module
PowerShell module for working with cURL.
## Install
```powershell
${MOD} = "cURL"; ${PFX} = "PkgStore"; ${DIR} = "$( (${env:PSModulePath} -split ';')[0] )"; Invoke-WebRequest "https://github.com/pkgstore/pwsh-${MOD}/archive/refs/heads/main.zip" -OutFile "${DIR}\${MOD}.zip"; Expand-Archive -Path "${DIR}\${MOD}.zip" -DestinationPath "${DIR}"; if ( Test-Path -Path "${DIR}\${PFX}.${MOD}" ) { Remove-Item -Path "${DIR}\${PFX}.${MOD}" -Recurse -Force }; Rename-Item -Path "${DIR}\pwsh-${MOD}-main" -NewName "${DIR}\${PFX}.${MOD}"; Remove-Item -Path "${DIR}\${MOD}.zip";
```
## Syntax
For syntax information, enter module info command and get help command.
```powershell
Get-Command -Module 'PkgStore.cURL'
```
```powershell
Get-Help '<COMMAND-NAME>'
```