Skip to content

Commit

Permalink
ci: upgrade to kcl
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Jan 12, 2025
1 parent fd9dd8d commit 55566a6
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 64 deletions.
120 changes: 56 additions & 64 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,78 +1,70 @@
name: Publish

on:
'on':
push:
branches:
- master
workflow_dispatch: {}
schedule:
- cron: '0 10,15,20 * * *'
- cron: '0 10,15,20 * * *'
workflow_dispatch: {}
repository_dispatch:
types: [publish]

types:
- publish
jobs:
github-pages:
job:
name: Github Pages
runs-on: ubuntu-22.04
permissions:
contents: read
pages: write
id-token: write
pages: write
id-token: write
contents: read
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Check out source repository
uses: actions/checkout@v2

- name: Download lock file
run: wget https://patch.discoverygc.com/patchlist.xml

- name: Cache Freelancer
id: cache-freelancer
uses: actions/cache@v3
with:
key: ${{ runner.os }}-freelancer-discovery-${{ hashFiles('patchlist.xml') }}
path: ${{ github.workspace }}/freelancer_folder
- name: Check out source repository
uses: actions/checkout@v3
- name: Download lock file
run: wget https://patch.discoverygc.com/patchlist.xml
- name: Cache Freelancer
uses: actions/cache@v3
with:
key: ${{ runner.os }}-freelancer-discovery-${{ hashFiles('patchlist.xml') }}
path: ${{ github.workspace }}/freelancer_folder
id: cache-freelancer
- name: Checkout Freelancer
if: ${{ steps.cache-freelancer.outputs.cache-hit != 'true' }}
uses: darklab8/infra/.github/actions/checkout-freelancer@master
with:
freelancer-mod: discovery
freelancer-folder: ${{ github.workspace }}/freelancer_folder
ssh-key-base64-discovery: ${{ secrets.ID_RSA_FILES_FREELANCER_DISCOVERY }}
- name: Install Go
uses: darklab8/infra/.github/actions/install-go@master
- name: Patch to latest
run: go run autopatch.go -wd ${{ github.workspace }}/freelancer_folder
- name: temporal fix to disco bugs
shell: python
run: |
filename = "${{ github.workspace }}/freelancer_folder/DATA/initialworld.ini"
with open(filename, "r") as file:
data = file.read()
- uses: darklab8/infra/.github/actions/checkout-freelancer@master
if: ${{ steps.cache-freelancer.outputs.cache-hit != 'true' }}
with:
freelancer-mod: "discovery"
freelancer-folder: ${{ github.workspace }}/freelancer_folder
ssh-key-base64-discovery: ${{ secrets.ID_RSA_FILES_FREELANCER_DISCOVERY }}
replaced = data.replace("rep = 0.-55, gd_im_grp", "rep = -0.55, gd_im_grp")
- name: Set up Go
uses: darklab8/infra/.github/actions/install-go@master

- name: Patch to latest
run: go run ${{ github.workspace }}/autopatch.go -wd ${{ github.workspace }}/freelancer_folder

- name: temporal fix to disco bugs
shell: python
run: |
filename = "${{ github.workspace }}/freelancer_folder/DATA/initialworld.ini"
with open(filename, "r") as file:
data = file.read()
replaced = data.replace("rep = 0.-55, gd_im_grp", "rep = -0.55, gd_im_grp")
with open(filename, "w") as file:
file.write(replaced)
- uses: darklab8/fl-darkstat/.github/actions/build@master
with:
site-root: "/fl-data-discovery/"
freelancer-folder: ${{ github.workspace }}/freelancer_folder
heading: <a href="https://github.com/darklab8/fl-darkstat">Darkstat</a> from <a href="https://darklab8.github.io/blog/pet_projects.html#Freelancercommunity">DarkTools</a> for <a href="https://github.com/darklab8/fl-data-discovery">Freelancer Discovery</a>
relay-host: "https://darkrelay.dd84ai.com"

- uses: actions/upload-pages-artifact@v1
with:
name: github-pages
path: ./build

# Turn on ability to deploy to pages in repository settings, Pages tab
# choose "Github Actions" deployment method to Pages
- name: Deploy to pages
uses: actions/deploy-pages@v1
id: deployment
with open(filename, "w") as file:
file.write(replaced)
- name: Darkstat Build
uses: darklab8/fl-darkstat/.github/actions/build@master
with:
site-root: /fl-data-discovery/
freelancer-folder: ${{ github.workspace }}/freelancer_folder
heading: <a href="https://github.com/darklab8/fl-darkstat">Darkstat</a> from <a href="https://darklab8.github.io/blog/pet_projects.html#Freelancercommunity">DarkTools</a> for <a href="https://github.com/darklab8/fl-data-discovery">Freelancer Discovery</a>
relay-host: https://darkrelay.dd84ai.com
- name: Upload artifacts for deployment to Github Pages
uses: actions/upload-pages-artifact@v1
with:
name: github-pages
path: './build'
- name: Deploy to pages
uses: actions/deploy-pages@v1
id: deployment
4 changes: 4 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ tasks:
- GOOS=linux GOARCH=arm64 go build -v -o dist/autopatch-linux-arm64 autopatch.go
- GOOS=windows GOARCH=amd64 go build -v -o dist/autopatch-windows-amd64.exe autopatch.go
- GOOS=windows GOARCH=arm64 go build -v -o dist/autopatch-windows-arm64.exe autopatch.go

kcl:build:
cmds:
- kcl kcls/build.k
10 changes: 10 additions & 0 deletions kcls/build.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import .wf_publish
import infra.kcls.common.workflow

import yaml

_workflows = [
wf_publish._workflow
]

_run = [yaml.dump_to_file(a, ".github/workflows/${a._filename}", ignore_private=True, ignore_none=True) for a in _workflows]
7 changes: 7 additions & 0 deletions kcls/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "kcls"
edition = "v0.11.0"
version = "0.0.1"

[dependencies]
infra = { path = "../../infra", version = "0.0.1" }
5 changes: 5 additions & 0 deletions kcls/kcl.mod.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[dependencies]
[dependencies.infra]
name = "infra"
full_name = "infra_0.0.1"
version = "0.0.1"
72 changes: 72 additions & 0 deletions kcls/wf_publish.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import infra.kcls.models.github_action as ga
import infra.kcls.models.github_workflow as gw
import infra.kcls.common.github as ghc
import infra.kcls.actions.checkout_freelancer as cf
import infra.kcls.actions.install_go
import infra.kcls.actions.darkstat

_freelancer_folder = r"${{ github.workspace }}/freelancer_folder"

_workflow = gw.Workflow {
_filename = "publish.yaml"
name = "Publish"
on = {
workflow_dispatch: {}
push.branches = ["master"]
schedule:[{cron="0 10,15,20 * * *"}]
repository_dispatch: {types: ["publish"]}
}
jobs = {
job = _publish_job
}
}
_publish_job: gw.Job = {
name = "Github Pages"
permissions: ghc.PagesPermissions {}
environment: dict(ghc.PagesEnvironment {})
steps = [
ghc.CheckoutRepo
ga.Step{
name = "Download lock file"
run = "wget https://patch.discoverygc.com/patchlist.xml"
}
ga.Step {
name = "Cache Freelancer"
id = "cache-freelancer"
uses = "actions/cache@v3"
with= {
key = r"${{ runner.os }}-freelancer-discovery-${{ hashFiles('patchlist.xml') }}"
path = _freelancer_folder
}
}
cf.NewCheckoutFreelancer(cf.CheckoutArgs {
freelancer_mod = cf._mod_discovery
freelancer_folder = _freelancer_folder
$if = r"${{ steps.cache-freelancer.outputs.cache-hit != 'true' }}"
})
install_go.InstallGo{}
ga.Step{
name = "Patch to latest"
run = "go run autopatch.go -wd ${_freelancer_folder}"
}
ga.Step{
name = "temporal fix to disco bugs"
shell = "python"
run = """filename = "${_freelancer_folder}/DATA/initialworld.ini"
with open(filename, "r") as file:
data = file.read()

replaced = data.replace("rep = 0.-55, gd_im_grp", "rep = -0.55, gd_im_grp")

with open(filename, "w") as file:
file.write(replaced)
"""
}
darkstat.Build(darkstat.BuildArgs{
site_root = "/fl-data-discovery/"
freelancer_folder = _freelancer_folder
heading = '<a href="https://github.com/darklab8/fl-darkstat">Darkstat</a> from <a href="https://darklab8.github.io/blog/pet_projects.html#Freelancercommunity">DarkTools</a> for <a href="https://github.com/darklab8/fl-data-discovery">Freelancer Discovery</a>'
relay_host = "https://darkrelay.dd84ai.com"
})
] + ghc.PagesToDeploySteps(ghc.PagesDeployOpts {})
}

0 comments on commit 55566a6

Please sign in to comment.