diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 47003eb..ccd142f 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -20,6 +20,20 @@ jobs: id: timestamp run: echo "::set-output name=date::$(date +'%Y%m%d_%H%M%S')" + - name: Install Dependencies + run: npm i + + - name: Create JSON Lines + run: node ./scripts/ndjson-out.js ./pis/codes.yaml + + - name: Verify JSONL Output + run: | + if [ ! -s pis-objects.jsonl ]; then + echo "Error: pis-objects.jsonl is empty or missong" + exit 1 + fi + echo "File verified" + - name: Create Release if: success() uses: akkuman/gitea-release-action@v1 @@ -30,3 +44,5 @@ jobs: tag_name: ${{ steps.timestamp.outputs.date }} name: ${{ steps.timestamp.outputs.date }} token: ${{ secrets.OWLBOT_KEY }} + files: | + release-data.jsonl diff --git a/scripts/ndjson-out.js b/scripts/ndjson-out.js new file mode 100644 index 0000000..f3d74f3 --- /dev/null +++ b/scripts/ndjson-out.js @@ -0,0 +1,27 @@ +const fs = require('fs'); +const yaml = require('yaml'); + +const inputFile = process.argv[2]; +const outputFile = 'pis-objects.jsonl'; + +if (!inputFile) { + console.error('Please provide an input YAML file'); + process.exit(1); +} + +try { + const fileContent = fs.readFileSync(inputFile, 'utf8'); + const data = yaml.loadAll(fileContent); + + if (!data || !data.pis || !Array.isArray(data.pis)) { + throw new Error('Invalid structure: Expected object with "pis" array.'); + } + + const jsonl = data.pis.map(item => JSON.stringify(item)); + + fs.writeFileSync(outputFile, jsonl.join('\n') + '\n'); + console.log(`Successfully processed ${data.pis.length} items.`); +} catch (e) { + console.error("Conversion failed: ", e.message); + process.exit(1); +} \ No newline at end of file diff --git a/scripts/test.yaml b/scripts/test.yaml new file mode 100644 index 0000000..e69de29