Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SCRIPT_BEFORE_REQUIRED and SCRIPT_AFTER_REQUIRED flags #141

Merged
merged 2 commits into from
Sep 24, 2023

Conversation

dbryan0516
Copy link
Contributor

Added SCRIPT_BEFORE_REQUIRED and SCRIPT_AFTER_REQUIRED flags for error throwing when remote script errors

When new flags are enabled and remote script fails, action will fail.

Addresses #115

usage:

...
      SCRIPT_BEFORE: |
        whoami
        ls -al
      SCRIPT_BEFORE_REQUIRED: true
      SCRIPT_AFTER: |
        whoami
        ls -al
        echo $RSYNC_STDOUT
      SCRIPT_AFTER_REQUIRED: true
...

NOTE: When using SCRIPT_BEFORE/AFTER to run a shell script (e.g. some_script.sh), script should include set -e to fail script when a single command fails so that the exit code is returned. Source

@mattpopovich
Copy link

Can't speak to the correctness of this PR, but would like to see this feature merged.

@easingthemes easingthemes merged commit 3ab5951 into easingthemes:main Sep 24, 2023
@leonard-pak
Copy link

Does this feature work? The SCRIPT_AFTER_REQUIRED key is marked as unexpected in my action.

@dbryan0516
Copy link
Contributor Author

@leonard-pak Looking at your commit 914... that triggered it. It may be an ordering issue. SCRIPT_AFTER may need to come before SCRIPT_AFTER_REQUIRED would be my best guess here

@skyArony
Copy link
Contributor

I had the same problem

Unexpected input(s) 'SCRIPT_BEFORE_REQUIRED', 'SCRIPT_AFTER_REQUIRED', valid inputs are ['SSH_PRIVATE_KEY', 'REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT', 'SOURCE', 'TARGET', 'ARGS', 'SSH_CMD_ARGS', 'EXCLUDE', 'SCRIPT_BEFORE', 'SCRIPT_AFTER']
      - name: Deploy
        uses: easingthemes/ssh-deploy@v4
        with:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
          ARGS: "-rlgoDzvc -i --delete"
          SOURCE: "./DockerEnv/Infra/"
          REMOTE_HOST: ${{ vars.REMOTE_HOST }}
          REMOTE_USER: ${{ vars.REMOTE_USER }}
          TARGET: ${{ vars.REMOTE_TARGET }}
          SCRIPT_BEFORE: >
            if [ ! -d "${{ vars.REMOTE_TARGET }}" ]; then mkdir -p "${{ vars.REMOTE_TARGET }}"; fi &&
            cd ${{ vars.REMOTE_TARGET }} && whoami && ls -al &&
            if [ -f docker-compose.yml ]; then docker compose down; fi
          SCRIPT_BEFORE_REQUIRED: true
          SCRIPT_AFTER: >
            cd ${{ vars.REMOTE_TARGET }} && whoami && ls -al &&
            chmod +x run.sh && ./run.sh prod &&
            echo $RSYNC_STDOUT
          SCRIPT_AFTER_REQUIRED: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants