Skip to content

Commit

Permalink
fix: build config
Browse files Browse the repository at this point in the history
  • Loading branch information
fiqryq committed May 19, 2024
1 parent 2fb5169 commit 5ac83ff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/release.yaml

This file was deleted.

22 changes: 22 additions & 0 deletions esbuild.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
const { build } = require('esbuild');
const fs = require('fs');

// Read GitHub secrets from environment variables
const ghToken = process.env.GH_TOKEN;
const openaiApiKey = process.env.OPENAI_API_KEY;

// Check if secrets are defined
if (!ghToken || !openaiApiKey) {
console.error('GitHub token or OpenAI API key is not defined');
process.exit(1);
}

// Write secrets to a file to be accessed by the build process
fs.writeFileSync(
'secrets.json',
JSON.stringify({ GH_TOKEN: ghToken, OPENAI_API_KEY: openaiApiKey })
);

build({
bundle: true,
Expand All @@ -8,4 +25,9 @@ build({
entryPoints: ['index.js'],
outfile: 'dist/index.js',
target: 'node20',
// Inject environment variables from GitHub secrets into build process
define: {
'process.env.GH_TOKEN': JSON.stringify(ghToken),
'process.env.OPENAI_API_KEY': JSON.stringify(openaiApiKey),
},
}).catch(() => process.exit(1));

0 comments on commit 5ac83ff

Please sign in to comment.