Search code examples
github-actions

Remove a line from file with github action


Basically the title. I have <meta name="robots" content="noindex"> on my Angular index.html file while developing and publishing on staging site. Now I'd like to have another Action that'll publish to production without that line.

This seems like a simple task that action can do. But my google-fu seems to fail me atm.


Solution

  • Figured it out. I just need create a shell script.

    #!/bin/bash
    
    grep -v -w "noindex" ./src/index.html > tmpindex
    mv tmpindex ./src/index.html
    

    And on the action file

    jobs:
      build:
        runs-on: ubuntu-20.04
        steps:
          - uses: actions/checkout@v3
          - run: |
             chmod +x ./deploy.sh
             ./deploy.sh