Skip to content

Commit def30cd

Browse files
committed
allow post_install_script
1 parent 28272c8 commit def30cd

4 files changed

Lines changed: 25 additions & 13 deletions

File tree

.github/dependabot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2
22
updates:
33
- package-ecosystem: github-actions
4-
directory: "/"
4+
directory: '/'
55
schedule:
66
interval: weekly

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ author: Shopify
44
inputs:
55
build_script:
66
description: Build script for building the repository before publishing.
7+
post_install_script:
8+
description: Script to run after dependencies are installed.
79
comment_command:
810
description: A comma seperated list of comment commands to trigger the action
911
default: '/snapit'

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ try {
3030
repo: payload.repository.name,
3131
};
3232

33+
const postInstallScript = core.getInput('post_install_script');
3334
const buildScript = core.getInput('build_script');
3435
const isGlobal = core.getInput('global_install') === 'true';
3536
const githubCommentIncludedPackages = core.getInput(
@@ -122,6 +123,11 @@ try {
122123
await exec('npm', ['ci']);
123124
}
124125

126+
// Run post install script after dependencies are installed
127+
if (postInstallScript) {
128+
await runScript(postInstallScript);
129+
}
130+
125131
await exec(changesetBinary, ['version', '--snapshot', versionPrefix]);
126132

127133
const {packages} = await getPackages(process.cwd());
@@ -155,17 +161,7 @@ try {
155161

156162
// Run after `changeset version` so build scripts can use updated versions
157163
if (buildScript) {
158-
const commands = buildScript.split('&&').map((cmd) => cmd.trim());
159-
for (const cmd of commands) {
160-
const [cmdName, ...cmdArgs] = cmd.split(/\s+/);
161-
try {
162-
await exec(cmdName, cmdArgs);
163-
} catch (error) {
164-
throw new Error(
165-
`Failed to run ${cmdName} ${cmdArgs.join(' ')}: ${error.message}`,
166-
);
167-
}
168-
}
164+
await runScript(buildScript);
169165
}
170166

171167
if (branch) {
@@ -274,3 +270,17 @@ try {
274270
} catch (error) {
275271
core.setFailed(error.message);
276272
}
273+
274+
async function runScript(script: string) {
275+
const commands = script.split('&&').map((cmd) => cmd.trim());
276+
for (const cmd of commands) {
277+
const [cmdName, ...cmdArgs] = cmd.split(/\s+/);
278+
try {
279+
await exec(cmdName, cmdArgs);
280+
} catch (error) {
281+
throw new Error(
282+
`Failed to run ${cmdName} ${cmdArgs.join(' ')}: ${error.message}`,
283+
);
284+
}
285+
}
286+
}

0 commit comments

Comments
 (0)