Skip to content

implement when clause for conditional actions #409

@plastikfan

Description

@plastikfan
# ==========================
# Actions
# ==========================
actions:

  # Transcode video with medium quality
  komp-2:
    cmd: "ffmpeg -i {{.path}} -q:v 2 {{.dir}}/{{.stem}}.mp4"
    # Only apply to large video files
    when: "isVideo && isLarge && !isHidden"

  # Transcode video with lower quality
  komp-18:
    cmd: "ffmpeg -i {{.path}} -q:v 18 {{.dir}}/{{.stem}}.mp4"
    when: "isVideo && size > 50MB"

  # Upload to S3 bucket if transcoded file exists
  upload-s3:
    cmd: "aws s3 cp {{.dir}}/{{.stem}}.mp4 s3://mybucket/"
    when: "exists({{.dir}}/{{.stem}}.mp4)"

  # Generate a thumbnail for video
  thumbnail:
    cmd: "ffmpeg -i {{.path}} -vf 'thumbnail' -frames:v 1 {{.dir}}/{{.stem}}.jpg"
    when: "isVideo"

# ==========================
# Pipelines
# ==========================
pipelines:

  # Full video workflow: transcode + thumbnail + upload
  video-workflow:
    steps:
      - komp-2
      - thumbnail
      - upload-s3

  # Quick low-quality workflow
  quick-transcode:
    steps:
      - komp-18
      - upload-s3

Other place-holders:

{{.path}}, {{.name}}, {{.dir}}, {{.stem}}, etc.

Conditional actions:

when: "isVideo && isLarge && !isHidden"

Use a simple embedded DSL

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions