Skip to content

Commit

Permalink
action supports --dry-run (#354)
Browse files Browse the repository at this point in the history
* action supports --dry-run

* update dryRunCommand
  • Loading branch information
jbolda authored Jul 24, 2024
1 parent e81201f commit 294a3c0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/action-supports-dry-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"action": patch:bug
---

The action now supports running in dry run mode. This enables testing of workflows and publish sequences prior to publishing.
2 changes: 1 addition & 1 deletion .changes/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
{
"command": "npm publish --provenance --access public",
"dryRunCommand": "echo publish here",
"dryRunCommand": "npm publish --provenance --access public --dry-run",
"pipe": true
},
{
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/run-version-or-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ jobs:
- name: sync lockfile
if: steps.covector.outputs.commandRan == 'version'
run: npm install
- name: covector publish --dry-run
uses: ./packages/action
with:
token: ${{ secrets.GITHUB_TOKEN }}
command: "publish"
dryRun: true
- name: create pull request
id: cpr
uses: peter-evans/create-pull-request@v6
Expand Down
4 changes: 4 additions & 0 deletions packages/action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ inputs:
description: The directory to run covector within.
required: false
default: ""
dryRun:
description: Run in dry-run mode which skips executing steps, and instead logs. Useful for testing a publish beforehand.
required: false
defaults: false
createRelease:
description: Opt-in to create a release on publish
required: false
Expand Down
9 changes: 8 additions & 1 deletion packages/action/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function* run(logger: Logger): Generator<any, any, any> {
? process.env.GITHUB_TOKEN || ""
: core.getInput("token");
const inputCommand = core.getInput("command");
const dryRun = core.getInput("dryRun") === "true";
const releaseCommitish =
core.getInput("releaseCommitish") || github.context.sha;

Expand Down Expand Up @@ -74,6 +75,7 @@ export function* run(logger: Logger): Generator<any, any, any> {
} else {
const covectored: CovectorStatus = yield covector({
logger,
dryRun,
command,
filterPackages,
cwd,
Expand Down Expand Up @@ -153,6 +155,7 @@ export function* run(logger: Logger): Generator<any, any, any> {
} else if (command === "version") {
const status: CovectorStatus = yield covector({
logger,
dryRun,
command: "status",
cwd,
});
Expand Down Expand Up @@ -207,6 +210,7 @@ export function* run(logger: Logger): Generator<any, any, any> {

const covectored: CovectorVersion = yield covector({
logger,
dryRun,
command,
filterPackages,
cwd,
Expand Down Expand Up @@ -238,7 +242,7 @@ export function* run(logger: Logger): Generator<any, any, any> {
renderAsYAML: covectoredSmushed,
});
} else if (command === "publish") {
const status = yield covector({ logger, command: "status", cwd });
const status = yield covector({ logger, dryRun, command: "status", cwd });
core.setOutput("status", status.response);

let covectored: CovectorPublish;
Expand All @@ -253,6 +257,7 @@ export function* run(logger: Logger): Generator<any, any, any> {
logger.debug(`Fetched context, owner is ${owner} and repo is ${repo}.`);
covectored = yield covector({
logger,
dryRun,
command,
filterPackages,
cwd,
Expand All @@ -270,6 +275,7 @@ export function* run(logger: Logger): Generator<any, any, any> {
} else {
covectored = yield covector({
logger,
dryRun,
command,
filterPackages,
cwd,
Expand Down Expand Up @@ -373,6 +379,7 @@ export function* run(logger: Logger): Generator<any, any, any> {

covectored = yield covector({
logger,
dryRun,
command,
filterPackages,
cwd,
Expand Down

0 comments on commit 294a3c0

Please sign in to comment.