-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(publish): replace default image before npm latest publish
- Loading branch information
1 parent
1be8638
commit 7d6e8c9
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
.github/workflows/scripts/replace-worker-version-in-js-file.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const commitSha = process.env.COMMIT_SHA; | ||
|
||
const filePath = path.join( | ||
__dirname, | ||
'../../../packages/artillery/lib/platform/aws-ecs/legacy/constants.js' | ||
); | ||
|
||
try { | ||
let content = fs.readFileSync(filePath, 'utf8'); | ||
|
||
// This regex matches "const DEFAULT_IMAGE_TAG" followed by any characters, and then an equal sign and more characters | ||
// until it reaches a semicolon or end of the line | ||
const regex = /const DEFAULT_IMAGE_TAG\s*=\s*(['"])[^'"]*?\1/; | ||
const replacement = `const DEFAULT_IMAGE_TAG = '${commitSha}'`; // Replace with commitSha in single quotes | ||
content = content.replace(regex, replacement); | ||
|
||
// Write the modified content back to the file | ||
fs.writeFileSync(filePath, content); | ||
|
||
// Verify by reading the content again and console logging it | ||
const verifyContent = fs.readFileSync(filePath, 'utf8'); | ||
console.log(verifyContent); | ||
|
||
if (!verifyContent.includes(commitSha)) { | ||
throw new Error('Failed to replace commit SHA in JS file'); | ||
} | ||
} catch (error) { | ||
console.error('Error occurred:', error); | ||
} |
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