Merge pull request #37 from gentlementlegen/feat/schema-validator #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Update Configuration" | |
on: | |
workflow_dispatch: | |
push: | |
jobs: | |
update: | |
name: "Update Configuration in manifest.json" | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.10.0" | |
- name: Install deps and run configuration update | |
run: | | |
yarn install --immutable --immutable-cache --check-cache | |
yarn tsc --noCheck --project tsconfig.json | |
- name: Update manifest configuration using GitHub Script | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const fs = require('fs'); | |
const path = require('path'); | |
const { pluginSettingsSchema } = require('./src/types/plugin-input'); | |
const manifestPath = path.resolve("${{ github.workspace }}", './manifest.json'); | |
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); | |
const configuration = JSON.stringify(pluginSettingsSchema); | |
manifest["configuration"] = JSON.parse(configuration); | |
const updatedManifest = JSON.stringify(manifest, null, 2) | |
console.log('Updated manifest:', updatedManifest); | |
fs.writeFileSync(manifestPath, updatedManifest); | |
- name: Commit and Push generated types | |
run: | | |
git config --global user.name 'ubiquity-os[bot]' | |
git config --global user.email 'ubiquity-os[bot]@users.noreply.github.com' | |
git add ./manifest.json | |
if [ -n "$(git diff-index --cached --name-only HEAD)" ]; then | |
git commit -m "chore: updated generated configuration" || echo "Lint-staged check failed" | |
git push origin HEAD:${{ github.ref_name }} | |
else | |
echo "No changes to commit" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |