Skip to content

Commit

Permalink
Add a Github workflow to generate the content of a wiki (#6188)
Browse files Browse the repository at this point in the history
  • Loading branch information
relent0r committed May 20, 2024
1 parent a5cf70f commit acb7c3a
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 10 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/wiki-generate-blueprints.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: FAF Wiki Generator for Blueprints

on:
workflow_dispatch:

jobs:

generate-blueprints:
runs-on: ubuntu-latest
defaults:
run:
shell: bash

steps:
# Checkout repos, FA repo is sparse checkout as it is quite large
- name: Checkout Brewlan Wikigen Repository
uses: actions/checkout@v4
with:
repository: The-Balthazar/BrewWikiGen
ref: master
path: ./brew-wiki-gen
# FA repo is sparse checkout as it is quite large and we dont won't to incur higher action minutes for no reason
- name: Checkout FAF Repository # -png folder doesnt exist yet, confirm location.
uses: actions/checkout@v4
with:
repository: FAForever/fa
ref: deploy/develop
path: ./fa
sparse-checkout-cone-mode: |
wiki
loc
lua/ui/help/unitscription.lua
lua/ui/help/tooltips.lua
lua/sim/AdjacencyBuffs.lua
lua/system/Blueprints.lua
units/*_unit.bp
units/*_LOD0.scm
projectiles
- name: Checkout FAF Wiki Repository
uses: actions/checkout@v4
with:
repository: FAForever/fa.wiki
ref: master
path: ./fa.wiki

- name: Install Lua 5.4
uses: leafo/gh-actions-lua@v10
with:
luaVersion: "5.4"

- name: Replace run.lua
run: |
sudo mv fa/wiki/Run.lua brew-wiki-gen/Run.lua
- name: Execute lua run
run: |
lua brew-wiki-gen/Run.lua --OutputDirectory="fa.wiki/" --WikiGeneratorDirectory="brew-wiki-gen/" --FADirectory="fa/"
- name: Upload as artifact
uses: actions/upload-artifact@v4
with:
name: Wiki
path: fa.wiki

#- name: Store the game version
# id: gameVersionJSON # but it is a string here!
# working-directory: app/data
# run: |
# json=`cat ./version.json`
# echo "json=$json" >> $GITHUB_OUTPUT

#- name: Update Wiki repository # but it is a string here!
# working-directory: fa.wiki
# run: |
# git config user.email "administrator@faforever.com"
# git config user.name "FAForever"

# git stage .
# git commit -m "Update generated data to game version ${{ fromJson(steps.gameVersionJSON.outputs.json).version}}"
# git push origin HEAD:master


73 changes: 73 additions & 0 deletions .github/workflows/wiki-generate-icons.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: FAF Wiki Generator for icons

on:
workflow_dispatch:

jobs:

generate-icons:
runs-on: ubuntu-latest
defaults:
run:
shell: bash

steps:
# Checkout repos

# FA repo is sparse checkout as it is quite large and we dont won't to incur higher action minutes for no reason
- name: Checkout FAF Repository # -png folder doesnt exist yet, confirm location.
uses: actions/checkout@v4
with:
repository: FAForever/fa
ref: deploy/develop
path: ./fa
sparse-checkout: |
wiki
textures/ui/common/game/strategicicons
textures/ui/common/icons/units
- name: Checkout FAF Wiki Repository
uses: actions/checkout@v4
with:
repository: FAForever/fa.wiki
ref: master
path: ./fa.wiki

- name: Install Image Magick
run: |
sudo apt-get install -y imagemagick
# copy strategic and unit icons and convert them to PNGs. Assume this should be going to the wiki location not the fa repo
- name: Convert Strategic Icons
working-directory: fa
run: |
wiki/icons-convert-strategic.sh
wiki/icons-convert-unit.sh
- name: Move Strategic Icons
run: |
mv -f fa/wiki/generated/strategicicons/*.png fa.wiki/icons/strategicicons
mv -f fa/wiki/generated/units/*.png fa.wiki/icons/units
- name: Upload as artifact
uses: actions/upload-artifact@v4
with:
name: Wiki
path: fa.wiki

# - name: Store the game version
# id: gameVersionJSON # but it is a string here!
# working-directory: app/data
# run: |
# json=`cat ./version.json`
# echo "json=$json" >> $GITHUB_OUTPUT

# - name: Update Wiki repository # but it is a string here!
# working-directory: fa.wiki
# run: |
# git config user.email "administrator@faforever.com"
# git config user.name "FAForever"

# git stage .
# git commit -m "Update generated data to game version ${{ fromJson(steps.gameVersionJSON.outputs.json).version}}"
# git push origin HEAD:master
1 change: 1 addition & 0 deletions changelog/snippets/other.6188.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6188) Create a Github workflow to automate the population of the Wiki
6 changes: 4 additions & 2 deletions tests/run-syntax-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ while read file; do
if [ "$file" != "./.vscode/fa-plugin.lua" ]; then
if [ "$file" != "./lua/system/class.lua" ]; then
if [ "$file" != "./lua/sim/NavGenerator.lua" ]; then
check_file "$file"
(( files_checked++ ))
if [ "$file" != "./wiki/Run.lua" ]; then
check_file "$file"
(( files_checked++ ))
fi
fi
fi
fi
Expand Down
40 changes: 36 additions & 4 deletions wiki/Run.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,52 @@
--[[ ---------------------------------------------------------------------- ]]--
local OutputDirectory = "D:/faf-development/fa.wiki/"
local WikiGeneratorDirectory = "D:/faf-development/BrewWikiGen/"
local FADirectory = "D:/faf-development/fa/"

-- This section deals with overriding the OutputDirectory and WikiGeneratorDirectory if required
local function parse_args(arg)
local args = {}
for i = 1, #arg do
local key, value = arg[i]:match("--([^=]+)=(.*)")
if key and value then
key = key:gsub("^%-+", "") -- Remove leading '-' characters
args[key] = value
end
end
return args
end

local args = parse_args(arg)

-- Overwrite default values if provided as command-line arguments
if args["OutputDirectory"] then
OutputDirectory = args["OutputDirectory"]
end
if args["WikiGeneratorDirectory"] then
WikiGeneratorDirectory = args["WikiGeneratorDirectory"]
end
if args["FADirectory"] then
FADirectory = args["FADirectory"]
end

print("Directories set")
print("Output Directory: " ..OutputDirectory)
print("Wiki Generator Directory: " ..WikiGeneratorDirectory)
print("FA Directory: " ..FADirectory)

EnvironmentData = {
name = 'Forged Alliance Forever',
author = 'Gas Powered Games',
version = '1.6.6',
icon = false,
location = 'D:/faf-development/fa/',
location = FADirectory,

GenerateWikiPages = true, --Generate pages for env blueprints
RebuildBlueprints = true, --Rebuild env blueprints
RunSanityChecks = false, --Sanity check env bps

Lua = 'D:/faf-development/fa/',
LOC = 'D:/faf-development/fa/',
Lua = FADirectory,
LOC = FADirectory,
-- ExtraData = '',

PreModBlueprints = {},
Expand All @@ -46,7 +78,7 @@ WikiOptions = {
BuildListSaysModUnits = true,

OnlineRepoUnitPageBlueprintLink = 'https://github.com/FAForever/fa/',
LocalRepuUnitPageBlueprintLink = 'D:/faf-development/fa/',
LocalRepuUnitPageBlueprintLink = FADirectory,
}

RebuildBlueprintOptions = {
Expand Down
4 changes: 2 additions & 2 deletions wiki/icons-convert-strategic.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ fi

mkdir "wiki/generated/strategicicons"

magick mogrify -path "wiki/generated/strategicicons" -format png "textures/ui/common/game/strategicicons/*.dds"
mogrify -path "wiki/generated/strategicicons" -format png "textures/ui/common/game/strategicicons/*.dds"

read -p "Press enter to continue"
#read -p "Press enter to continue"
4 changes: 2 additions & 2 deletions wiki/icons-convert-unit.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ fi

mkdir "wiki/generated/units"

magick mogrify -path "wiki/generated/units" -format png "textures/ui/common/icons/units/*.dds"
mogrify -path "wiki/generated/units" -format png "textures/ui/common/icons/units/*.dds"

read -p "Press enter to continue"
#read -p "Press enter to continue"

0 comments on commit acb7c3a

Please sign in to comment.