trigger processing #72
This file contains hidden or 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: Build and Deploy Types | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build types | |
| run: npm run build:types | |
| - name: Generate package.json | |
| run: | | |
| node -e " | |
| const fs = require('fs'); | |
| const rootPkg = require('./package.json'); | |
| // Combine all dependencies from the root package.json | |
| const rootDeps = { ...rootPkg.dependencies, ...rootPkg.devDependencies }; | |
| const typeDeps = {}; | |
| const explicitTypePackages = ['@xterm/xterm', 'howler']; | |
| for (const [pkgName, version] of Object.entries(rootDeps)) { | |
| if (pkgName.startsWith('@types/') || explicitTypePackages.includes(pkgName)) { | |
| typeDeps[pkgName] = version; | |
| } | |
| } | |
| // Define the package.json for the 'types' branch | |
| // It reuses many fields from the root package.json | |
| const typesPkg = { | |
| name: rootPkg.name, | |
| version: rootPkg.version, | |
| description: rootPkg.description, | |
| main: 'index.js', | |
| types: 'index.d.ts', // Assumes 'index.d.ts' is the main entry point in your 'types' dir | |
| repository: rootPkg.repository, | |
| author: rootPkg.author, | |
| license: rootPkg.license, | |
| keywords: rootPkg.keywords, | |
| bugs: rootPkg.bugs, | |
| homepage: rootPkg.homepage, | |
| dependencies: typeDeps | |
| }; | |
| // Write the new package.json into the 'types' directory | |
| fs.writeFileSync('./types/package.json', JSON.stringify(typesPkg, null, 2)); | |
| console.log('Generated package.json in ./types/package.json'); | |
| // Optional: Create a dummy index.js to satisfy the 'main' field | |
| if (!fs.existsSync('./types/index.js')) { | |
| fs.writeFileSync('./types/index.js', '// This file is intentionally blank. See package.json for types entry point.\n'); | |
| console.log('Created dummy ./types/index.js'); | |
| } | |
| " | |
| - name: Deploy to 'types' branch | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| branch: types | |
| folder: types | |
| clean: true | |
| - name: Emit Repository Dispatch | |
| run: | | |
| curl -L \ | |
| -X POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| https://api.github.com/repos/obfuscatedgenerated/ollieos_test_pkg/dispatches \ | |
| -d '{"event_type": "ollieos_updated"}' |