Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/new-repository.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: New Repository Request
description: Request adding a new BattleScribe data repository to the gallery
title: "Add repository: "
labels: ["new-repository"]
body:
- type: input
id: repo-url
attributes:
label: Repository URL
description: Full GitHub URL of the repository to add
placeholder: "https://github.com/owner/repo-name"
validations:
required: true
- type: checkboxes
id: prerequisites
attributes:
label: Prerequisites
options:
- label: Repository is publicly accessible
required: true
- label: Repository has the `battlescribe-data` topic
- label: Repository has a published release with a `.catpkg.json` asset
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Description

<!-- Briefly describe the change -->

## Type of Change

- [ ] New repository registration
- [ ] Registry entry update/fix
- [ ] Workflow/script change
- [ ] Documentation update

## Checklist

- [ ] Entry file is named `<repo-name>.catpkg.yml`
- [ ] Entry contains valid `location.github` field
- [ ] Repository is publicly accessible
- [ ] Repository has the `battlescribe-data` topic (recommended)
2 changes: 1 addition & 1 deletion .github/actions/install-yaml/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ runs:
steps:
- run: |
Import-Module powershell-yaml -ErrorAction:Ignore
|| Install-Module powershell-yaml -RequiredVersion 0.4.2 -Force
|| Install-Module powershell-yaml -RequiredVersion 0.4.7 -Force
shell: pwsh
121 changes: 0 additions & 121 deletions .github/scripts/Update-GhPagesData.ps1

This file was deleted.

15 changes: 8 additions & 7 deletions .github/scripts/Update-Registry.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ param (
[string] $RegistryPath,

[Parameter()]
[string] $Token
[string] $Token,

[Parameter()]
[string] $ParentOrgName = 'BSData'
)

#Requires -Version 7
#Requires -Module powershell-yaml

$parentOrgName = 'BSData'

$query = "topic:battlescribe-data+org:$parentOrgName"
$query = "topic:battlescribe-data+org:$ParentOrgName"
$apiRepoSearchArgs = @{
Method = 'GET'
Uri = "https://api.github.com/search/repositories?q=$query"
Expand All @@ -22,7 +23,7 @@ $apiRepoSearchArgs = @{
}
}
if ($Token) {
$apiRepoSearchArgs.Headers['Authorization'] = "token $token"
$apiRepoSearchArgs.Headers['Authorization'] = "Bearer $Token"
}
$apiRepoSearchResult = Invoke-RestMethod @apiRepoSearchArgs
$repositories = @($apiRepoSearchResult.items | Sort-Object full_name)
Expand Down Expand Up @@ -57,7 +58,7 @@ $reposNoLongerExisting = $regEntries | Where-Object {
# we've got it in API response, so it surely exists
return $false
}
if ($reponame -match "^$parentOrgName/" -and $reponame -notin $orgRepoNames) {
if ($reponame -match "^$ParentOrgName/" -and $reponame -notin $orgRepoNames) {
# we've not got it in API response and it's from requested org,
# so it doesn't meet search criteria (e.g. no 'battlescribe-data' topic)
$_.del_reason = "not found in org repos query results"
Expand All @@ -68,7 +69,7 @@ $reposNoLongerExisting = $regEntries | Where-Object {
Uri = "https://api.github.com/repos/$reponame"
StatusCodeVariable = 'status'
SkipHttpErrorCheck = $true
Headers = ($Token ? @{ Authorization = "token $Token" } : @{})
Headers = ($Token ? @{ Authorization = "Bearer $Token" } : @{})
}
$null = Invoke-RestMethod @apiRepoGetArgs
$notFound = $status -eq 404
Expand Down
24 changes: 6 additions & 18 deletions .github/scripts/Validate-Registry.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,16 @@ if ($env:GITHUB_ACTIONS -ne 'true') {
function LogError($Message, $File) {
Write-Error "$File`: $Message"
}
function FormatFileRef($props, $msg) {
$file = $props['file']
$line = $props['line']
$col = $props['col']
$value = ''
if ($file) {
$position = $line ? $col ? "($line,$col)" : "($line)" : '';
$value += "${file}${position}: "
}
return $value + $message
}
}
else {
function LogDebug($Message) {
Write-ActionDebug $Message
Write-Host "::debug::$Message"
}
function LogWarning($Message, $File) {
Write-ActionWarning $Message $File
Write-Host "::warning file=$File::$Message"
}
function LogError($Message, $File) {
Write-ActionError $Message $File
Write-Host "::error file=$File::$Message"
}
}

Expand Down Expand Up @@ -82,9 +71,8 @@ Get-ChildItem $entriesDir *.catpkg.yml | Sort-Object Name | ForEach-Object {
StatusCodeVariable = 'status'
SkipHttpErrorCheck = $true
Headers = @{
# preview api for 'topics'
Accept = 'application/vnd.github.mercy-preview+json'
} + ($Token ? @{ Authorization = "token $Token" } : @{} )
Accept = 'application/vnd.github.v3+json'
} + ($Token ? @{ Authorization = "Bearer $Token" } : @{} )
}
$apiRepo = Invoke-RestMethod @apiRepoArgs
if ($status -ne 200) {
Expand All @@ -106,7 +94,7 @@ Get-ChildItem $entriesDir *.catpkg.yml | Sort-Object Name | ForEach-Object {
Uri = "$apiUrl/contents/.github/workflows"
StatusCodeVariable = 'status'
SkipHttpErrorCheck = $true
Headers = ($Token ? @{ Authorization = "token $Token" } : @{} )
Headers = ($Token ? @{ Authorization = "Bearer $Token" } : @{} )
}
$workflows = Invoke-RestMethod @getWorkflowsArgs
$addWorkflowsSuggestion = @"
Expand Down
16 changes: 16 additions & 0 deletions .github/scripts/lib/BsdataGallery/BsdataGallery.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@{
RootModule = 'BsdataGallery.psm1'
ModuleVersion = '1.0.0'
GUID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
Author = 'BSData'
Description = 'PowerShell module for BSData Gallery index operations'
PowerShellVersion = '7.0'
RequiredModules = @('powershell-yaml')
FunctionsToExport = @(
'Update-BsdataGalleryIndex'
'Get-BsdataGalleryCatpkg'
)
CmdletsToExport = @()
VariablesToExport = @()
AliasesToExport = @()
}
6 changes: 3 additions & 3 deletions .github/scripts/lib/BsdataGallery/BsdataGallery.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function Get-GHApiUpdatedResult {
Headers = & {
$requestHeaders = @{ }
if ($Token) {
$requestHeaders['Authorization'] = "token $Token"
$requestHeaders['Authorization'] = "Bearer $Token"
}
if ($LastModified) {
$requestHeaders['If-Modified-Since'] = $LastModified
Expand Down Expand Up @@ -172,7 +172,7 @@ function Get-UpdatedCache {
[string]$Token,

[Parameter()]
[string]$DisableLastModifiedCaching
[switch]$DisableLastModifiedCaching
)

# prepare result object
Expand Down Expand Up @@ -289,7 +289,7 @@ function Update-BsdataGalleryIndex {
[string]$Token,

[Parameter()]
[string]$DisableLastModifiedCaching
[switch]$DisableLastModifiedCaching
)

# read registry entries
Expand Down
31 changes: 16 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/install-yaml
- name: Validate registry
uses: Amadevus/pwsh-script@v2
with:
script: |
$ErrorActionPreference = 'Continue'
$entries = @()
if ($github.base_ref) {
# we are in a pull request, let's only check changed entries
$baseRefBranch = 'refs/heads/base'
git fetch --depth=1 origin "+$($github.base_ref):$baseRefBranch" | Out-Host
# get a list of files changed in PR
$entries = git diff-tree --no-commit-id --name-only -r HEAD $baseRefBranch
Write-Host "Changed files:"
$entries | Out-Host
}
./.github/scripts/Validate-Registry.ps1 -Entries $entries -Token $github.token
shell: pwsh
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
$ErrorActionPreference = 'Continue'
$entries = @()
if ($env:GITHUB_BASE_REF) {
# we are in a pull request, let's only check changed entries
$baseRefBranch = 'refs/heads/base'
git fetch --depth=1 origin "+$($env:GITHUB_BASE_REF):$baseRefBranch" | Out-Host
# get a list of files changed in PR
$entries = git diff-tree --no-commit-id --name-only -r HEAD $baseRefBranch
Write-Host "Changed files:"
$entries | Out-Host
}
./.github/scripts/Validate-Registry.ps1 -Entries $entries -Token $env:GITHUB_TOKEN
Loading
Loading