Skip to main content
Actions are reusable steps. When you author an action, you can add it to your workflow like you would other actions, by clicking the + button below any step. Pipedream provides two ways to share code across workflows:

Publish an action from a Node.js code step

You can publish any of your Node.js code steps into a reusable action. This enables you to write a Node.js code step once, and reuse it across many workflows without rewriting it. To convert a Node.js code step into an publishable action, make sure to include the below properties in your Node.js step:
  • version
  • name
  • key
  • type
// Adding properties to a regular Node.js code step make it publishable
import { parseISO, format } from 'date-fns';
 
// Returns a formatted datetime string
export default defineComponent({
  name: 'Format Date',
  version: '0.0.1',
  key: 'format-date',
  type: 'action',
  props: {
    date: {
      type: "string",
      label: "Date",
      description: "Date to be formatted",
    },
    format: {
      type: 'string',
      label: "Format",
      description: "Format to apply to the date. [See date-fns format](https://date-fns.org/v2.29.3/format) as a reference."
    }
  },
  async run({ $ }) {
    const formatted = format(parseISO(this.date), this.format);
    return formatted;
  },
})
 
Click Test to verify the step is working as expected. Only actions that have been successfully tested are to be published. Then open the menu in the top right hand corner of the code step and select Publish to My Actions: