Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
ci: update build replace script
Browse files Browse the repository at this point in the history
- add missing API_URL env variable
  • Loading branch information
sjdonado committed Jan 31, 2024
1 parent 40393d2 commit dac4d36
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
run: npm ci --legacy-peer-deps
- name: Setup firebase api key
working-directory: client
run: npm run build:update ${{ secrets.FIREBASE_API_KEY }}
run: npm run build:update FIREBASE_API_KEY=${{ secrets.FIREBASE_API_KEY }} LAMBDA_API_URL=${{ secrets.LAMBDA_API_URL }}
- name: Build
working-directory: client
env:
Expand Down
27 changes: 18 additions & 9 deletions client/replace.build.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
const replace = require('replace-in-file');
const firebaseApikey = process.argv[2];

const options = {
files: 'src/environments/environment.prod.ts',
from: /{API_KEY}/g,
to: firebaseApikey,
allowEmptyPaths: false,
};
const args = process.argv.slice(2);
const replacements = args.map(arg => {
const [key, value] = arg.split("=");

return {
files: 'src/environments/environment.prod.ts',
from: new RegExp(`{${key}}`, 'g'),
to: value,
allowEmptyPaths: false,
};
});

try {
replace.sync(options);
replacements.forEach((replacement) => {
const results = replace.sync(replacement);
if(results[0].hasChanged === true){
console.log(`Replaced ${replacement.from} in file ${replacement.files}`);
}
});
}
catch (error) {
console.error('Error occurred:', error);
}
}
4 changes: 2 additions & 2 deletions client/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export const environment = {
domain: 'mihorarioun.web.app',
secure: true,
},
apiUrl: 'https://e3pc8k5p2g.execute-api.us-east-1.amazonaws.com/dev/api/v1',
apiUrl: '{LAMBDA_API_URL}',
firebase: {
apiKey: '{API_KEY}',
apiKey: '{FIREBASE_API_KEY}',
authDomain: 'mihorarioun.firebaseapp.com',
databaseURL: '',
projectId: 'mihorarioun',
Expand Down

0 comments on commit dac4d36

Please sign in to comment.