old_contents: def _impl(ctx):
    output = ctx.outputs.out
    ctx.file_action(output=output, content=ctx.attr.content)
  
  file = rule(
      implementation=_impl,
      attrs={"content": attr.string()},
      outputs={"out": "%{name}.txt"},
  )
  
new_contents: def _impl(ctx):
    output = ctx.outputs.out
    ctx.actions.write(output=output, content=ctx.attr.content)
  
  file = rule(
      implementation=_impl,
      attrs={"content": attr.string()},
      outputs={"out": "%{name}.txt"},
  )
  
subject: Update example to new API (use ctx.actions.write)