How to check a Website for an error as a last step?

For example if an error is found curl -s | grep -i error, execute up rollback.

Any tips how to achieve that?

Not a bash script expert, but you could count the number of lines and conditionally execute a command like so:

errors=$(curl -s | grep -i error | wc -l)
if [[ $errors -ne 0 ]]; then up rollback; fi

Problem is I don’t understand how to roll that into a Workflow… :laughing:

Well, I can only guess that this is about and that you deploy a website somehow and want to revert to the previous version using up rollback if errors are found. Is there no way to check for errors before it’s deployed to a server?

How and when do you want to execute the check? Do you already have a workflow which does the deployment? In that case, just add my code snippet as a step like so:

    runs-on: ...
      - name: Deploy
        uses: apex/actions/up@v0.5.1 # is that what you use?
      - name: Check for errors
        run: |
          errors=$(curl -s | grep -i error | wc -l)
          if [[ $errors -ne 0 ]]; then up rollback; fi

This assumes that up has the credentials configured somehow (I don’t know how that works). The apex/actions/up action does not seem to support passing arguments at a first glance, which would allow one to execute the rollback and leave the configuration handling to that official action. But you should double-check that.

1 Like