Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retain workflow status #18

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

retain workflow status #18

wants to merge 6 commits into from

Conversation

Stamsy
Copy link
Contributor

@Stamsy Stamsy commented Aug 1, 2024

No description provided.

Copy link
Contributor

@perseus-algol perseus-algol left a comment

Choose a reason for hiding this comment

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

How about to add a flag "--activate, -a" here https://github.com/digital-boss/n8n-manager/blob/main/src/cli/workflows.ts#L168 ? Also it could have a default value = true, if you think that it would be more convenient in usage.

if (opts.dry === false) {
await wf.publish(...args)
await wf.deactivate(wfFilter) // Deactivate to avoid conflict
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please clarify why we need to deactivate workflows before publishing? The comment, BTW, doesn't do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We deactivate the workflow before publishing to avoid conflicts that can arise when activating a workflow that might already have active triggers or schedules, which n8n doesn’t handle well. More details about this issue can be found here: Workflow could not be activated.

console.error(`Failed to activate ${wf.id}:`, error);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There is already activate method in this class. This one duplicates the existing one logic. Use existing one instead.

@perseus-algol perseus-algol removed the request for review from valentina98 September 12, 2024 15:32
@perseus-algol
Copy link
Contributor

Remove activate flag.
Instead add two flags:

  • deactivate-before
  • do-not-activate

Both false by default. In the description of do-not-activate also mention that if false - the activation process will be performed for published workflows, in that case published wf will be activated only if it has active flag = true in it's json.

if (opts.dry === false) {
await wf.deactivate(wfFilter) // Deactivate to avoid conflict
await wf.publish(...args);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually it was correct to place deactivate inside that if. We making changes only if it is not dry run. Same below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8man issue - the workflows are not activated after publishing
2 participants