Create multiline file in GitHub Action


In this workflow example you can see several ways to creta a file from a GitHub Action workflow.

I am not sure if doing so is a good practice or not, I'd probbaly have a file someone in the repository and a script that will copy it, if necessary. Then I'd call that script in my YAML file.


examples/workflows/create_file.yml
name: Create file

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Create file
      run: |
        printf "Hello\nWorld\n" > hw.txt

    - name: Create file
      run: |
        echo First        > other.txt
        echo Second Line >> other.txt
        echo Third       >> other.txt


    - name: Show file content
      run: |
        pwd
        ls -la
        cat hw.txt
        cat other.txt


    - name: Create directory and create file in homedir
      run: |
        ls -la ~/
        mkdir ~/.zorg
        echo First        > ~/.zorg/home.txt
        echo Second Line >> ~/.zorg/home.txt
        echo Third       >> ~/.zorg/home.txt
        ls -la ~/.zorg/

    - name: Show file content
      run: |
        ls -la ~/
        cat ~/.zorg/home.txt