Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
directory: '/'
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettier did this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problems with this!

schedule:
interval: weekly
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ author: Shopify
inputs:
build_script:
description: Build script for building the repository before publishing.
post_install_script:
description: Script to run after dependencies are installed.
comment_command:
description: A comma seperated list of comment commands to trigger the action
default: '/snapit'
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

32 changes: 21 additions & 11 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ try {
repo: payload.repository.name,
};

const postInstallScript = core.getInput('post_install_script');
const buildScript = core.getInput('build_script');
const isGlobal = core.getInput('global_install') === 'true';
const githubCommentIncludedPackages = core.getInput(
Expand Down Expand Up @@ -122,6 +123,11 @@ try {
await exec('npm', ['ci']);
}

// Run post install script after dependencies are installed
if (postInstallScript) {
await runScript(postInstallScript);
}

await exec(changesetBinary, ['version', '--snapshot', versionPrefix]);

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

// Run after `changeset version` so build scripts can use updated versions
if (buildScript) {
const commands = buildScript.split('&&').map((cmd) => cmd.trim());
for (const cmd of commands) {
const [cmdName, ...cmdArgs] = cmd.split(/\s+/);
try {
await exec(cmdName, cmdArgs);
} catch (error) {
throw new Error(
`Failed to run ${cmdName} ${cmdArgs.join(' ')}: ${error.message}`,
);
}
}
await runScript(buildScript);
}

if (branch) {
Expand Down Expand Up @@ -274,3 +270,17 @@ try {
} catch (error) {
core.setFailed(error.message);
}

async function runScript(script: string) {
const commands = script.split('&&').map((cmd) => cmd.trim());
for (const cmd of commands) {
const [cmdName, ...cmdArgs] = cmd.split(/\s+/);
try {
await exec(cmdName, cmdArgs);
} catch (error) {
throw new Error(
`Failed to run ${cmdName} ${cmdArgs.join(' ')}: ${error.message}`,
);
}
}
}