Repository: kestra-io/kestra (java)

Issue:
Issue with Escaping Curly Braces in YAML for Kestra
### Describe the issue

Like I already wrote in this post: https://github.com/kestra-io/kestra/issues/4087 which was instantly closed without even waiting for an answer like everyone would be just dump, I will ask it here again.

Also the `line: {% raw %}{{ item }}{% endraw %}` does not work in this case like described in the documentation.

```yml
id: server-init-essentials
namespace: homelab.dev

labels:
  project: Ubuntu-Servers
  step: essentials

variables:
  username: "abc"
  hosts: ["192.168.122.159"] # ["192.168.122.159", "192.168.122.160"]

tasks:
  - id: server-init-essentials
    type: io.kestra.plugin.core.flow.WorkingDirectory
    inputFiles:
      inventory.ini: |
        {% for host in vars.hosts %}
        {{ host }} ansible_port=2222
        {% endfor %}
      myplaybook.yml: |
        ---
        - hosts: all
          become: true
          tasks:
            - name: Insert content into /tmp/rc.local
              ansible.builtin.lineinfile:
                path: /tmp/rc.local
                line: {% raw %}{{ item }}{% endraw %}
                create: true
              loop:
                - '#!/bin/sh -e'
                - 'sysctl -p /etc/sysctl.d/42-disable-ipv6.conf'
                - 'exit 0'

    tasks:
      - id: execute_playbook
        type: io.kestra.plugin.ansible.cli.AnsibleCLI
        namespaceFiles:
          enabled: true
        docker:
          image: cytopia/ansible:latest-tools
          pullPolicy: IF_NOT_PRESENT
          user: "1000"
        commands:
          - ansible-playbook -i inventory.ini myplaybook.yml --key-file kestra/secrets/id_ed25519_dev.key
        env:
          ANSIBLE_HOST_KEY_CHECKING: "False"
          ANSIBLE_REMOTE_USER: "{{ vars.username }}"
 ```
throws the error:
```txt
Failed preExecuteTasks on WorkingDirectory: Unable to find `item` used in the expression `---
- hosts: all
  become: true
  tasks:
    - name: Insert content into /tmp/rc.local
      ansible.builtin.lineinfile:
        path: /tmp/rc.local
        line: {{ item }}
        create: true
      loop:
        - '#!/bin/sh -e'
        - 'sysctl -p /etc/sysctl.d/42-disable-ipv6.conf'
        - 'exit 0'
` at line 8
```
Doing the same but inside a real playbook file and executing it like this, does work.
```yml
id: server-init-essentials
namespace: homelab.dev

labels:
  project: Ubuntu-Servers
  step: essentials

variables:
  username: "abc"
  hosts: ["192.168.122.159"] # ["192.168.122.159", "192.168.122.160"]

tasks:
  - id: server-init-essentials
    type: io.kestra.plugin.core.flow.WorkingDirectory
    inputFiles:
      inventory.ini: |
        {% for host in vars.hosts %}
        {{ host }} ansible_port=2222
        {% endfor %}
    tasks:
      - id: execute_playbook
        type: io.kestra.plugin.ansible.cli.AnsibleCLI
        namespaceFiles:
          enabled: true
        docker:
          image: cytopia/ansible:latest-tools
          pullPolicy: IF_NOT_PRESENT
          user: "1000"
        commands:
          - ansible-playbook -i inventory.ini pb_temp.yml --key-file kestra/secrets/id_ed25519_dev.key
        env:
          ANSIBLE_HOST_KEY_CHECKING: "False"
          ANSIBLE_REMOTE_USER: "{{ vars.username }}"
 ```
 `pb_temp.yml` content.
 ```yml
 ---
- hosts: all
  become: true
  tasks:
    - name: Insert content into /tmp/rc.local
      ansible.builtin.lineinfile:
        path: /tmp/rc.local
        line: '{{ item }}'
        create: true
      loop:
        - '#!/bin/sh -e'
        - 'sysctl -p /etc/sysctl.d/42-disable-ipv6.conf'
        - 'exit 0'
```

So a simple how to this line should looks like would be enough. What is wrong in this:
`line: {% raw %}{{ item }}{% endraw %}`

### Environment

- Kestra Version: 0.17.4
- Operating System (Docker):

Pull request description:
fix(core): FileService render twice the input files
Fixes #4093

Patch:
diff --git a/core/src/main/java/io/kestra/core/runners/FilesService.java b/core/src/main/java/io/kestra/core/runners/FilesService.java
index a21c808d7..26b6d9cc1 100644
--- a/core/src/main/java/io/kestra/core/runners/FilesService.java
+++ b/core/src/main/java/io/kestra/core/runners/FilesService.java
@@ -39,17 +39,16 @@ public abstract class FilesService {
                      file.getParentFile().mkdirs();
                  }
 
-                 var fileContent = runContext.render(input, additionalVars);
-                 if (fileContent == null) {
+                 if (input == null) {
                     file.createNewFile();
                  } else {
-                     if (fileContent.startsWith("kestra://")) {
-                         try (var is = runContext.storage().getFile(URI.create(fileContent));
+                     if (input.startsWith("kestra://")) {
+                         try (var is = runContext.storage().getFile(URI.create(input));
                               var out = new FileOutputStream(file)) {
                              IOUtils.copyLarge(is, out);
                          }
                      } else {
-                         Files.write(file.toPath(), fileContent.getBytes());
+                         Files.write(file.toPath(), input.getBytes());
                      }
                  }
              }));


Test patch:
diff --git a/core/src/test/java/io/kestra/core/runners/FilesServiceTest.java b/core/src/test/java/io/kestra/core/runners/FilesServiceTest.java
index 50b71ff4e..588212de3 100644
--- a/core/src/test/java/io/kestra/core/runners/FilesServiceTest.java
+++ b/core/src/test/java/io/kestra/core/runners/FilesServiceTest.java
@@ -34,6 +34,13 @@ class FilesServiceTest {
         assertThat(content.get("file.txt"), is("Hello World"));
     }
 
+    @Test
+    void renderRawFile() throws Exception {
+        RunContext runContext = runContextFactory.of(Map.of("filename", "file.txt", "content", "Hello World"));
+        Map<String, String> content = FilesService.inputFiles(runContext, Map.of("{{filename}}", "{% raw %}{{content}}{% endraw %}"));
+        assertThat(content.get("file.txt"), is("{{content}}"));
+    }
+
     @Test
     void outputFiles() throws Exception {
         RunContext runContext = runContextFactory.of();