Skip to content

Commit

Permalink
Add guide links workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
janslifka committed Jan 22, 2025
1 parent fe9b896 commit 7ac3ab5
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 5 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/guide-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Guide Links CI

on:
push:
tags:
- v*

jobs:
pot:
name: Create guide links
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 20 ]

steps:
- name: '[setup] Checkout Project'
uses: actions/checkout@v4

- name: '[setup] Node.js ${{ matrix.node-version }}'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: '[app] Install'
run: |
npm ci
- name: '[app] Create Guide Links'
run: |
npm run guide-links
- name: '[release] Check Prerelease'
id: check_prerelease
run: |
GITHUB_TAG=`echo $GITHUB_REF | cut -d/ -f3`
if [[ $GITHUB_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
fi
- name: '[release] Create & Upload Artifacts'
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "guide-links.json"
artifactContentType: application/json
prerelease: ${{ steps.check_prerelease.outputs.is_prerelease }}
replacesArtifacts: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ engine-wizard/static/wizard/config.js
# locale
!*/locale
/locale

# guide links
guide-links.json
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
"build:registry": "COMPONENT=registry ./scripts/build.sh",
"build:wizard": "COMPONENT=wizard ./scripts/build.sh",
"clean": "rm -rf dist",
"guide-links": "node scripts/create-guide-links.js",
"pot": "mkdir -p locale && npm run pot:registry && npm run pot:wizard",
"pot:registry": "COMPONENT=registry node scripts/create-pot-file.js",
"pot:wizard": "COMPONENT=wizard node scripts/create-pot-file.js",
"review": "elm-review",
"start": "npm run start:wizard",
"start:registry": "COMPONENT=registry webpack serve",
"start:wizard": "COMPONENT=wizard webpack serve",
Expand All @@ -16,11 +21,7 @@
"test:registry": "npm run test:elm",
"test:wizard": "npm run test:elm && npm run test:wizard:icon-set && npm run test:wizard:locale",
"test:wizard:icon-set": "COMPONENT=wizard node scripts/test-icon-set.js",
"test:wizard:locale": "COMPONENT=wizard node scripts/test-locale.js",
"review": "elm-review",
"pot": "mkdir -p locale && npm run pot:registry && npm run pot:wizard",
"pot:registry": "COMPONENT=registry node scripts/create-pot-file.js",
"pot:wizard": "COMPONENT=wizard node scripts/create-pot-file.js"
"test:wizard:locale": "COMPONENT=wizard node scripts/test-locale.js"
},
"devDependencies": {
"@lydell/elm": "^0.19.1-14",
Expand Down
14 changes: 14 additions & 0 deletions scripts/create-guide-links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fs = require('fs')


const elmFile = 'engine-wizard/elm/Wizard/Common/GuideLinks.elm'
const fileContent = fs.readFileSync(elmFile, 'utf8')
const keyValueRegex = /\( "(.*?)", "(.*?)" \)/g
const result = {}

let line
while ((line = keyValueRegex.exec(fileContent)) !== null) {
result[line[1]] = line[2]
}

fs.writeFileSync('guide-links.json', JSON.stringify(result, null, 2))

0 comments on commit 7ac3ab5

Please sign in to comment.