### Example BATS Test Setup Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Illustrates a setup function within a BATS test file. Setup functions are executed before each test case and are used for initializing test environments. ```bash setup() { # Initialize SSH agent and add key ssh-agent -s > /dev/null echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null # Create dummy source directory and files mkdir -p /tmp/source echo "hello" > /tmp/source/file1.txt echo "world" > /tmp/source/file2.txt } ``` -------------------------------- ### BATS Test Setup Phase with Mock Binaries Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/testing-reference.md Demonstrates the setup phase in a BATS test, creating mock executables for 'source', 'agent-start', 'agent-add', and 'rsync' to simulate dependencies and capture arguments. ```bats setup() { # Create dummy binaries for sourcing echo 'echo "source"' > source echo 'echo "agent started"' > agent-start echo 'echo "key added"' > agent-add chmod +x source agent-start agent-add # Create dummy rsync binary to capture its arguments echo 'echo "rsync $@"' > rsync chmod +x rsync PATH="$PWD:$PATH" } ``` -------------------------------- ### Example Dockerfile for Rsync Deployments Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Shows a Dockerfile used to build a custom image for the rsync-deployments action. It specifies the base image, installs necessary packages, and configures the environment. ```dockerfile FROM alpine:3.23.4 RUN apk add --no-cache rsync openssh-client openssl busybox COPY entrypoint.sh /entrypoint.sh COPY rsync-deployments /rsync-deployments RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] ``` -------------------------------- ### SSH Agent Command Example Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/helper-scripts.md Demonstrates the use of the 'ssh-agent' command. This command is used to start and manage the SSH agent process. ```shell ssh-agent ``` -------------------------------- ### Example Rsync Command Construction Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Illustrates the construction of a complex rsync command with various options for deployment. This example includes common switches for synchronization and exclusion. ```bash rsync -avz --delete --exclude 'node_modules/' --exclude '.git/' -e "ssh -p $SSH_PORT" $SOURCE_DIR $SSH_USER@$SSH_HOST:$DESTINATION_DIR ``` -------------------------------- ### Basic Rsync Deployment Example Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/action-inputs.md This example demonstrates a basic rsync deployment using common switches and specifying the source path, remote path, host, port, user, and a deploy key. ```yaml - name: Deploy via rsync uses: burnett01/rsync-deployments@v8 with: switches: -avzr --delete path: src/ remote_path: /var/www/html/ remote_host: example.com remote_port: 22 remote_user: ubuntu remote_key: ${{ secrets.DEPLOY_KEY }} ``` -------------------------------- ### Touch Command Example Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/helper-scripts.md Demonstrates the use of the 'touch' command to create files. This is a standard Unix utility used by the hosts-init script. ```shell touch ``` -------------------------------- ### Install BATS Core Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/testing-reference.md Instructions for installing BATS Core on macOS, Ubuntu, or from source. ```bash # Install BATS on macOS brew install bats-core # Install BATS on Ubuntu apt-get install bats # Install BATS from source git clone https://github.com/bats-core/bats-core.git cd bats-core ./install.sh /usr/local ``` -------------------------------- ### Install Rsync on Alpine Linux Source: https://github.com/burnett01/rsync-deployments/blob/master/README.md Install rsync using the apk package manager on Alpine Linux. ```bash sudo apk add rsync ``` -------------------------------- ### BATS Test Structure Example Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/testing-reference.md Illustrates the basic structure of a BATS test file, including setup, teardown, and test case definitions. ```bats #!/usr/bin/env bats setup() { # Runs before each test # Set up test environment, create fixtures } teardown() { # Runs after each test # Clean up temporary files } @test "test description" { # Test body # Uses BATS functions: run, [ ], [[ ]], etc. } ``` -------------------------------- ### Create Directory Command Example Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/helper-scripts.md Demonstrates the use of the 'mkdir' command to create directories. This is a standard Unix utility used by the ssh-init script. ```shell mkdir ``` -------------------------------- ### Example Helper Script: agent-start Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Contains the source code for the 'agent-start' helper script. This script ensures that an SSH agent is running and accessible. ```bash #!/bin/bash # Start SSH agent if not already running if ! pgrep -u "$(id -u)" ssh-agent > /dev/null 2>&1; then echo "Starting SSH agent..." ssh-agent > /dev/null eval "$(ssh-agent -s)" else echo "SSH agent is already running." fi exit 0 ``` -------------------------------- ### Rsync Command Not Found Error Example Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/rsync-integration.md Example of 'rsync: command not found' error, indicating that rsync is not installed on the remote server. Solution involves installing rsync on the remote system. ```text rsync: command not found ``` -------------------------------- ### Verify rsync Installation Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/troubleshooting-guide.md Confirm that rsync is installed and accessible on the remote server. Use 'which rsync' to check the path and 'rsync --version' to verify the installation. ```bash which rsync rsync --version ``` -------------------------------- ### Example Helper Script: hosts-init Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Provides the source code for the 'hosts-init' helper script. This script is used to initialize the known_hosts file with the correct SSH host keys. ```bash #!/bin/bash # Initialize known_hosts file with SSH host keys # Ensure SSH directory exists if [ ! -d "$HOME/.ssh" ]; then mkdir -p "$HOME/.ssh" chmod 700 "$HOME/.ssh" fi # Add host keys to known_hosts if [ -n "$SSH_HOST" ]; then echo "Adding SSH host key for $SSH_HOST..." ssh-keyscan -p "$SSH_PORT" "$SSH_HOST" >> "$HOME/.ssh/known_hosts" chmod 644 "$HOME/.ssh/known_hosts" else echo "SSH_HOST not set. Skipping host key addition." fi exit 0 ``` -------------------------------- ### RSH Example: With Custom Port and Additional Options Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/rsync-integration.md An example RSH configuration demonstrating the use of a non-standard SSH port and additional custom options, such as verbose output. ```sh ssh -o StrictHostKeyChecking=no -p 2222 -v ``` -------------------------------- ### Example Helper Script: ssh-init Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Demonstrates the source code for the 'ssh-init' helper script. This script is responsible for initializing SSH infrastructure, including setting up the SSH agent and managing keys. ```bash #!/bin/bash # Initialize SSH agent and add keys # Ensure SSH agent is running if ! pgrep -u "$(id -u)" ssh-agent > /dev/null 2>&1; then ssh-agent > /dev/null eval "$(ssh-agent -s)" fi # Add private key to the agent if [ -n "$SSH_PRIVATE_KEY" ]; then echo "Adding SSH private key to agent..." echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - ssh-add -l else echo "SSH_PRIVATE_KEY not set. Skipping key addition." fi # Set strict host key checking to no if specified if [ "$SSH_STRICT_HOST_KEY_CHECKING" = "false" ]; then echo "Disabling strict host key checking." mkdir -p "$HOME/.ssh" echo -e "Host * StrictHostKeyChecking no UserKnownHostsFile=/dev/null" > "$HOME/.ssh/config" fi exit 0 ``` -------------------------------- ### Install Rsync on CentOS/RHEL/Rocky/AlmaLinux Source: https://github.com/burnett01/rsync-deployments/blob/master/README.md Install rsync using yum or dnf on CentOS, RHEL, Rocky Linux, or AlmaLinux. ```bash sudo yum install rsync ``` ```bash # OR on newer versions: sudo dnf install rsync ``` -------------------------------- ### Install Rsync on Ubuntu/Debian Source: https://github.com/burnett01/rsync-deployments/blob/master/README.md If rsync is not found on the remote host, install it using apt-get on Ubuntu or Debian-based systems. ```bash sudo apt-get update && sudo apt-get install rsync ``` -------------------------------- ### Example Action Input: SOURCE_DIR Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Defines the source directory for the rsync deployment. This input parameter specifies the local path containing the files to be deployed. ```yaml SOURCE_DIR: 'dist/' ``` -------------------------------- ### Example Action Input: EXTRA_ARGS Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Allows passing additional arguments directly to the rsync command. This provides flexibility for advanced rsync configurations. ```yaml EXTRA_ARGS: '--dry-run' ``` -------------------------------- ### Install Core Packages with APK Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/docker-image-reference.md Installs essential packages including rsync, openssh, openssl, and busybox using Alpine's package manager (apk). The --no-cache and --upgrade flags ensure the latest versions are installed without leaving cache files. ```dockerfile RUN apk update && apk add --no-cache --upgrade rsync openssh openssl busybox ``` -------------------------------- ### Container Entrypoint Configuration Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/docker-image-reference.md Defines the default executable that runs when a container is started. This script handles initialization, deployment, and cleanup. ```dockerfile ENTRYPOINT ["/entrypoint.sh"] ``` -------------------------------- ### Example Helper Script: hosts-add Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Shows the source code for the 'hosts-add' helper script. This script adds additional SSH host keys to the known_hosts file. ```bash #!/bin/bash # Add additional SSH host keys to known_hosts if [ -n "$SSH_HOSTS_EXTRA" ]; then echo "Adding extra SSH host keys..." echo "$SSH_HOSTS_EXTRA" | while IFS= read -r host; do ssh-keyscan -p "$SSH_PORT" "$host" >> "$HOME/.ssh/known_hosts" done chmod 644 "$HOME/.ssh/known_hosts" else echo "SSH_HOSTS_EXTRA not set. Skipping extra host key addition." fi exit 0 ``` -------------------------------- ### Configuring Environment Protection Rules Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/deployment-workflow.md This example demonstrates how to set up environment protection rules for a deployment environment. This includes requiring a specific number of reviewers and automatically dismissing stale approvals. ```yaml environment: name: production protection-rules: - required-reviewers: 1 - dismiss-stale-approvals: true ``` -------------------------------- ### Create Test Workflow for Integration Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/testing-reference.md Example GitHub Actions workflow snippet for integration testing with a remote server. ```yaml - uses: burnett01/rsync-deployments@v8 with: switches: -avzr --delete --dry-run path: ./test-files/ remote_host: localhost remote_port: 2222 remote_user: root remote_key: ${{ secrets.TEST_KEY }} remote_path: /tmp/test-deploy/ ``` -------------------------------- ### Logging Deployment Information Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/deployment-workflow.md This example logs key deployment information such as the Git ref, commit SHA, and author to the workflow logs. This is useful for tracking and auditing deployments. ```yaml - name: Log deployment info run: | echo "Deploying: ${{ github.ref }}" echo "Commit: ${{ github.sha }}" echo "Author: ${{ github.actor }} ``` -------------------------------- ### Check Installed Packages and Versions within Container Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/docker-image-reference.md Commands to run inside the container to list installed packages and check the versions of rsync and SSH. ```bash # List installed packages docker run rsync-deployments:8.0.5 apk list --installed # Check rsync version docker run rsync-deployments:8.0.5 rsync --version # Check SSH version docker run rsync-deployments:8.0.5 ssh -V ``` -------------------------------- ### RSH Example: With Legacy RSA Keys Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/rsync-integration.md An example RSH configuration that includes flags for supporting legacy RSA host keys, in addition to disabling strict host key checking. ```sh ssh -o StrictHostKeyChecking=no -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa -p 22 ``` -------------------------------- ### Basic CD Workflow with rsync Deployments Source: https://github.com/burnett01/rsync-deployments/blob/master/README.md This example demonstrates a typical Continuous Deployment workflow using the rsync deployments action. It checks out the code and then uses the action to deploy specified files to a remote host. Ensure all required secrets are configured in your GitHub repository. ```yaml name: DEPLOY on: push: branches: - master jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - name: rsync deployments uses: burnett01/rsync-deployments@v8 with: switches: -avzr --delete path: src/ remote_path: ${{ secrets.REMOTE_PATH }} # ex: /var/www/html/ remote_host: ${{ secrets.REMOTE_HOST }} # ex: example.com remote_port: ${{ secrets.REMOTE_PORT }} # ex: 22 remote_user: ${{ secrets.REMOTE_USER }} # ex: ubuntu remote_key: ${{ secrets.REMOTE_PRIVATE_KEY }} ``` -------------------------------- ### Troubleshoot Container Startup and Command Issues Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/docker-image-reference.md Provides commands to check Docker image syntax, verify the existence of the entrypoint script, list installed packages, and check the availability of essential tools like rsync and ssh. ```bash # Check image syntax docker build --no-cache . # Verify entrypoint exists docker run --entrypoint sh rsync-deployments -c 'ls -la /entrypoint.sh' # Check which packages installed docker run rsync-deployments apk list --installed | grep -E 'rsync|openssh|openssl' # Verify tool availability docker run rsync-deployments which rsync docker run rsync-deployments ssh -V ``` -------------------------------- ### Start SSH Agent Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/entrypoint-execution.md Starts a new SSH agent or reuses an existing one, setting up necessary environment variables like SSH_AGENT_PID and SSH_AUTH_SOCK. It uses the GITHUB_ACTION identifier for the agent session. ```sh source agent-start "$GITHUB_ACTION" ``` -------------------------------- ### RSH Example: Default (No Host Key Verification) Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/rsync-integration.md An example of the RSH variable configuration when no strict host key verification is enabled. This is the default behavior. ```sh ssh -o StrictHostKeyChecking=no -p 22 ``` -------------------------------- ### Build Docker Image with Build Arguments Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/docker-image-reference.md Example of building the Docker image while specifying a build argument for the Alpine Linux version. This allows for customization during the build process. ```bash docker build --build-arg ALPINE_VERSION=3.23.4 -t rsync-deployments . ``` -------------------------------- ### Setup Mock Rsync Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/testing-reference.md Creates a mock rsync script for debugging. This script captures and echoes the arguments it receives to standard error. ```bash setup() { # Add debugging to mock rsync cat > rsync << 'EOF' #!/bin/sh echo "DEBUG: rsync called with: $@" >&2 echo "rsync $@" EOF } ``` -------------------------------- ### Example Helper Script: agent-add Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Shows the source code for the 'agent-add' helper script. This script adds an SSH private key to the running SSH agent. ```bash #!/bin/bash # Add SSH private key to agent if [ -n "$SSH_PRIVATE_KEY" ]; then echo "Adding SSH private key to agent..." echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - ssh-add -l else echo "SSH_PRIVATE_KEY not set. Skipping key addition." fi exit 0 ``` -------------------------------- ### Example Rsync Command for Syncing Source Directory Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Illustrates a basic rsync command for synchronizing a source directory to a remote destination. This is a fundamental operation for deployment. ```bash rsync -avz -e "ssh -p $SSH_PORT" $SOURCE_DIR $SSH_USER@$SSH_HOST:$DESTINATION_DIR ``` -------------------------------- ### Example Rsync Command for File Exclusion Problems Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Illustrates an rsync command where file exclusion might be misconfigured, leading to unexpected files being transferred or excluded. This example highlights the exclusion syntax. ```bash rsync -avz --exclude '*.log' --exclude 'temp/' -e "ssh -p $SSH_PORT" $SOURCE_DIR $SSH_USER@$SSH_HOST:$DESTINATION_DIR ``` -------------------------------- ### Start SSH Agent Source: https://github.com/burnett01/rsync-deployments/blob/master/docker-rsync/README.md Starts the SSH agent if not already running. This command needs to be sourced to work correctly. It accepts an optional agent name, defaulting to 'default'. ```shell source agent-start "default" ``` -------------------------------- ### Production Deployment Workflow on Push Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/deployment-workflow.md A complete workflow example for deploying to production when changes are pushed to the main branch. Includes build steps and rsync deployment with production-specific secrets. ```yaml name: Deploy to Production on: push: branches: - main jobs: deploy: name: Production Deployment runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Build application run: | npm install npm run build - name: Deploy via rsync uses: burnett01/rsync-deployments@v8 with: switches: -avzr --delete path: build/ remote_path: /var/www/html/ remote_host: ${{ secrets.PROD_HOST }} remote_port: ${{ secrets.PROD_PORT }} remote_user: ${{ secrets.PROD_USER }} remote_key: ${{ secrets.PROD_KEY }} ``` -------------------------------- ### RSH Example: With Strict Host Key Checking Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/rsync-integration.md An example RSH configuration that enforces strict host key checking, requiring known hosts to be verified against the UserKnownHostsFile. ```sh ssh -o UserKnownHostsFile=/root/.ssh/known_hosts -o StrictHostKeyChecking=yes -p 22 ``` -------------------------------- ### Install rsync on Remote Server (CentOS/RHEL) Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/troubleshooting-guide.md Install the rsync package on CentOS or RHEL-based systems using yum. This resolves 'rsync: command not found' errors. ```bash sudo yum install -y rsync ``` -------------------------------- ### Example Rsync Command for Empty Remote Path Validation Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Shows an rsync command that might trigger validation for an empty remote path. This example focuses on the command structure. ```bash rsync -avz -e "ssh -p $SSH_PORT" $SOURCE_DIR $SSH_USER@$SSH_HOST: ``` -------------------------------- ### Echo Command Example Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/helper-scripts.md Demonstrates the use of the 'echo' command to output text. This is a standard Unix utility used in various scripts for piping data. ```shell echo ``` -------------------------------- ### SSH Add Command Example Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/helper-scripts.md Demonstrates the use of the 'ssh-add' command to load keys into the SSH agent. This command is used by the agent-add script. ```shell ssh-add ``` -------------------------------- ### Example Rsync Command with Extra Arguments Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Demonstrates how to pass additional arguments to the rsync command. This allows for fine-tuning rsync behavior beyond the standard options. ```bash rsync -avz --delete --exclude 'node_modules/' --exclude '.git/' -e "ssh -p $SSH_PORT" $EXTRA_ARGS $SOURCE_DIR $SSH_USER@$SSH_HOST:$DESTINATION_DIR ``` -------------------------------- ### Chmod Command Example Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/helper-scripts.md Demonstrates the use of the 'chmod' command to set file permissions. This is a standard Unix utility used by the ssh-init and hosts-init scripts. ```shell chmod ``` -------------------------------- ### Example Action Input: SSH_PRIVATE_KEY Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Provides the SSH private key for authentication with the remote server. This input should be a secret stored in GitHub Actions. ```yaml SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} ``` -------------------------------- ### Example Action Input: SSH_HOSTS_EXTRA Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt A string containing a list of additional hostnames or IP addresses for which SSH host keys should be fetched and added to known_hosts. ```yaml SSH_HOSTS_EXTRA: 'host1.example.com host2.example.com' ``` -------------------------------- ### Example Helper Script: hosts-clear Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Presents the source code for the 'hosts-clear' helper script. This script clears the known_hosts file, which can be useful for troubleshooting host key issues. ```bash #!/bin/bash # Clear known_hosts file if [ -f "$HOME/.ssh/known_hosts" ]; then echo "Clearing known_hosts file..." rm -f "$HOME/.ssh/known_hosts" else echo "known_hosts file not found. Skipping clear." fi exit 0 ``` -------------------------------- ### Example Action Input: DESTINATION_DIR Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Specifies the destination directory on the remote server where files will be deployed. This input parameter defines the target path for the rsync operation. ```yaml DESTINATION_DIR: '/var/www/my-app' ``` -------------------------------- ### Example Helper Script: agent-askpass Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Contains the source code for the 'agent-askpass' helper script. This script provides a mechanism for entering an SSH passphrase when needed. ```bash #!/bin/bash # SSH agent askpass program if [ -n "$SSH_ASKPASS_PASSWORD" ]; then echo "$SSH_ASKPASS_PASSWORD" else echo "SSH_ASKPASS_PASSWORD not set." exit 1 fi exit 0 ``` -------------------------------- ### Example Action Input: SSH_HOST Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt The hostname or IP address of the remote server for the SSH connection. This input specifies the target machine for deployment. ```yaml SSH_HOST: 'production.server.com' ``` -------------------------------- ### Example Action Input: EXCLUDE Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt A list of files or directories to exclude from the rsync transfer. This input allows you to skip specific items during deployment. ```yaml EXCLUDE: 'node_modules/' ``` -------------------------------- ### Example Action Input: SSH_USER Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt The username to use for the SSH connection to the remote server. This input specifies the user account on the target machine. ```yaml SSH_USER: 'deployer' ``` -------------------------------- ### Example Rsync Command with Legacy RSA Key Support Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Shows how to enable legacy RSA key support for SSH connections when using rsync. This might be necessary for older SSH servers or specific key configurations. ```bash rsync -avz -e "ssh -o "HostKeyAlgorithms=+ssh-rsa" -p $SSH_PORT" $SOURCE_DIR $SSH_USER@$SSH_HOST:$DESTINATION_DIR ``` -------------------------------- ### Example Rsync Command for Partial Transfers (Exit Code 23) Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Demonstrates an rsync command that might result in exit code 23, often indicating a partial transfer due to network issues or file changes during transfer. This example focuses on the command structure. ```bash rsync -avz --partial --progress -e "ssh -p $SSH_PORT" $SOURCE_DIR $SSH_USER@$SSH_HOST:$DESTINATION_DIR ``` -------------------------------- ### Truncate Command Example Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/helper-scripts.md Demonstrates the use of the 'truncate' command to clear file contents. This is a standard Unix utility used by the hosts-clear script. ```shell truncate ``` -------------------------------- ### Example Rsync Command with Dry Run Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Shows an rsync command configured with the '--dry-run' option. This is useful for testing deployment configurations without making actual changes to the destination. ```bash rsync -avz --delete --exclude 'node_modules/' --exclude '.git/' -e "ssh -p $SSH_PORT" --dry-run $SOURCE_DIR $SSH_USER@$SSH_HOST:$DESTINATION_DIR ``` -------------------------------- ### Example GitHub Actions Workflow Pattern Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Illustrates a complete workflow pattern within a GitHub Actions YAML file. This serves as a template for setting up automated deployments. ```yaml name: Deploy to Production on: push: branches: - main jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: '20' - name: Install dependencies run: npm ci - name: Build project run: npm run build - name: Deploy to production uses: ./rsync-deployments with: SOURCE_DIR: 'dist/' DESTINATION_DIR: '/var/www/my-app' SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} SSH_HOST: 'production.server.com' SSH_USER: 'deployer' SSH_PORT: 22 EXCLUDE: 'node_modules/' DELETE_REMOTE: 'true' EXTRA_ARGS: '--dry-run' ``` -------------------------------- ### Example Helper Script: agent-stop Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Provides the source code for the 'agent-stop' helper script. This script stops the running SSH agent process. ```bash #!/bin/bash # Stop SSH agent if pgrep -u "$(id -u)" ssh-agent > /dev/null 2>&1; then echo "Stopping SSH agent..." eval "$(ssh-agent -k)" else echo "SSH agent is not running." fi exit 0 ``` -------------------------------- ### Rsync Deployment with Passphrase-Protected Key Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/action-inputs.md This example shows how to configure the action for deployments when the SSH private key is protected by a passphrase. It includes the `remote_key_pass` input for providing the passphrase. ```yaml - name: Deploy via rsync uses: burnett01/rsync-deployments@v8 with: switches: -avzr --delete path: build/ remote_path: /opt/app/ remote_host: ${{ secrets.REMOTE_HOST }} remote_port: ${{ secrets.REMOTE_PORT }} remote_user: ${{ secrets.REMOTE_USER }} remote_key: ${{ secrets.REMOTE_KEY }} remote_key_pass: ${{ secrets.REMOTE_KEY_PASS }} ``` -------------------------------- ### Deployment with Pre/Post Slack Notifications Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/deployment-workflow.md This workflow demonstrates how to integrate Slack notifications before and after a deployment. It includes steps for sending 'started' and 'success/failure' messages using `curl`. ```yaml name: Deploy with Notifications on: push: branches: - main jobs: deploy: name: Deploy runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Notify Slack - Deployment Started run: | curl -X POST ${{ secrets.SLACK_WEBHOOK }} \ -H 'Content-Type: application/json' \ -d '{"text":"Deployment started for ''${{ github.sha }}''..."}' - name: Build application run: | npm install npm run build - name: Deploy via rsync uses: burnett01/rsync-deployments@v8 id: deploy with: switches: -avzr --delete path: dist/ remote_path: /var/www/app/ remote_host: ${{ secrets.REMOTE_HOST }} remote_user: ${{ secrets.REMOTE_USER }} remote_key: ${{ secrets.REMOTE_KEY }} - name: Notify Slack - Deployment Success if: success() run: | curl -X POST ${{ secrets.SLACK_WEBHOOK }} \ -H 'Content-Type: application/json' \ -d '{"text":"✅ Deployment successful!"}' - name: Notify Slack - Deployment Failed if: failure() run: | curl -X POST ${{ secrets.SLACK_WEBHOOK }} \ -H 'Content-Type: application/json' \ -d '{"text":"❌ Deployment failed!"}' ``` -------------------------------- ### Caching Dependencies to Avoid Rebuilds Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/deployment-workflow.md This example shows how to use the actions/cache action to cache npm dependencies. This speeds up subsequent builds by avoiding the need to reinstall `node_modules`. ```yaml - uses: actions/cache@v3 with: path: node_modules key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} ``` -------------------------------- ### Implementing Health Checks Post-Deployment Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/deployment-workflow.md This example shows how to implement health checks after a deployment to ensure the application is functioning correctly. It includes a delay and checks two different endpoints. ```yaml - name: Health check run: | sleep 10 curl -f https://example.com/health || exit 1 curl -f https://example.com/api/status || exit 1 ``` -------------------------------- ### Dockerfile for Rsync Deployment Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/rsync-integration.md This Dockerfile installs necessary packages like rsync, openssh, and openssl on an Alpine Linux base image. It ensures a minimal footprint for fast action startup. ```dockerfile RUN apk add --no-cache --upgrade rsync openssh openssl busybox ``` -------------------------------- ### Manage Packages with APK on Alpine Linux Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/docker-image-reference.md Illustrates common commands for the Alpine Package Manager (APK), including updating repository metadata, adding, removing, listing installed packages, searching for packages, and retrieving package information. ```bash # Alpine package manager apk update # Refresh repository metadata apk add package # Install package apk del package # Remove package apk list --installed # List installed packages apk search pattern # Search for package apk info package # Get package information ``` -------------------------------- ### Set up Test Server with Docker Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/testing-reference.md Launches a minimal SSH test server using Docker for integration testing. ```bash # Set up minimal test server docker run -d --name test-ssh \ -p 2222:22 \ rastasheep/ubuntu-sshd:18.04 ``` -------------------------------- ### Rsync Deployment with Legacy RSA Host Keys Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/action-inputs.md Configure deployments to servers that may use legacy RSA host keys. This is useful for compatibility with older SSH setups. ```yaml - name: Deploy via rsync uses: burnett01/rsync-deployments@v8 with: switches: -avzr --delete legacy_allow_rsa_hostkeys: "true" path: src/ remote_path: /home/user/website/ remote_host: old-server.example.com remote_port: 22 remote_user: www-data remote_key: ${{ secrets.SSH_KEY }} ``` -------------------------------- ### Example Rsync Command for Path Not Found on Remote Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Illustrates an rsync command that could lead to a 'Path not found' error on the remote server. This typically occurs if the DESTINATION_DIR does not exist or is misspelled. ```bash rsync -avz -e "ssh -p $SSH_PORT" $SOURCE_DIR $SSH_USER@$SSH_HOST:/non/existent/path/ ``` -------------------------------- ### Verify SSH Key Format Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/troubleshooting-guide.md Check the first line of an SSH private key file to ensure it starts with '-----BEGIN OPENSSH PRIVATE KEY-----'. ```sh # Should start with BEGIN (not BEGIN RSA or BEGIN PRIVATE KEY with extra text) head -1 deploy_key ``` -------------------------------- ### Initialize SSH Directory Source: https://github.com/burnett01/rsync-deployments/blob/master/docker-rsync/README.md Creates the $HOME/.ssh folder with default permissions of 700. ```shell ssh-init ``` -------------------------------- ### SSH Permission Denied Error Example Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/rsync-integration.md Example of a 'Permission denied' error during SSH connection, often caused by an incorrect SSH key, unreachable host, or firewall issues. ```text Permission denied (publickey,password) ssh: connect to host ... port 22: Connection refused ``` -------------------------------- ### Configure Strict Host Key Checking Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/testing-reference.md Verifies the complete strict host key checking workflow, including SSH-keyscan, host key display, adding to known_hosts, and rsync using strict options. This test requires complex setup with mock binaries. ```bats local -r HOME="/tmp" export INPUT_LEGACY_ALLOW_RSA_HOSTKEYS="false" export INPUT_STRICT_HOSTKEYS_CHECKING="true" # ... other variables ... # Generate a mock key pair to test ssh-keyscan rm -f "$HOME/mockKeyPair" "$HOME/mockKeyPair.pub" \ && ssh-keygen -t ed25519 -f "$HOME/mockKeyPair" -N '' -q -C '' \ && mockPublicKey=$(< "$HOME/mockKeyPair.pub") # Create dummy ssh-keyscan binary to return $mockPublicKey echo "echo 'localhost.local $mockPublicKey #Mock 1'" > ssh-keyscan chmod +x ssh-keyscan # Create dummy hosts-add binary to capture its arguments echo 'echo "hosts-add $@"' > hosts-add chmod +x hosts-add run ./entrypoint.sh [[ "${output}" == *"hosts-add localhost.local ssh-ed25519"* ]] [[ "${output}" == *"rsync -avz -e ssh -o UserKnownHostsFile=/tmp/.ssh/known_hosts -o StrictHostKeyChecking=yes -p 22 /tmp/ user@localhost.local:remote/"* ]] ``` ```sh STRICT_HOSTKEYS_CHECKING="-o UserKnownHostsFile=$HOME/.ssh/known_hosts -o StrictHostKeyChecking=yes" key="$(ssh-keyscan -p "$INPUT_REMOTE_PORT" "$INPUT_REMOTE_HOST" 2>/dev/null | sed '/^#/d')" if [ -n "$key" ]; then echo "$key" | ssh-keygen -lf - echo "$key" | while IFS= read -r line; do hosts-add "$line"; done fi ``` -------------------------------- ### Build and Run Custom Rsync Deployments Docker Image Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/docker-image-reference.md Demonstrates the process of cloning the repository, building a custom Docker image, and running it locally for testing with specific environment variables and volume mounts. ```bash # Clone repository git clone https://github.com/Burnett01/rsync-deployments.git cd rsync-deployments # Modify Dockerfile if needed # ... edit Dockerfile ... # Build custom image docker build -f Dockerfile -t my-rsync-deployments:latest . # Test locally docker run --rm \ -e INPUT_SWITCHES="-avz --dry-run" \ -e INPUT_REMOTE_PATH="/tmp/test/" \ -e INPUT_REMOTE_HOST="localhost" \ -e INPUT_REMOTE_USER="user" \ -e INPUT_REMOTE_KEY="$(cat ~/.ssh/id_rsa)" \ -v $(pwd):/github/workspace:ro \ my-rsync-deployments:latest ``` -------------------------------- ### Example BATS Test Case Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt Provides an example of a test case written using the BATS (Bash Automated Testing System) framework. This demonstrates how to test the functionality of shell scripts. ```bash @test "rsync command works" { run bash -c "rsync -avz --delete --exclude 'node_modules/' $SOURCE_DIR $SSH_USER@$SSH_HOST:$DESTINATION_DIR" [ "$status" -eq 0 ] } ``` -------------------------------- ### Initialize Known Hosts File Source: https://github.com/burnett01/rsync-deployments/blob/master/docker-rsync/README.md Creates the known_hosts file ($HOME/.ssh/known_hosts) with default permissions of 600. ```shell hosts-init ``` -------------------------------- ### Start or Reuse SSH Agent Session Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/helper-scripts.md Starts a new SSH agent or reuses an existing one based on session files. It manages `SSH_AGENT_PID` and `SSH_AUTH_SOCK` environment variables. This script must be sourced. ```shell #!/bin/sh set -eu FOLDER=${1:-default} STORE_PATH="/tmp/ssh-agent/$FOLDER" mkdir -p "$STORE_PATH" if [ -z "${SSH_AGENT_PID:-}" ]; then if [ -f "$STORE_PATH/id" ]; then SSH_AGENT_PID=$(cat "$STORE_PATH/id") export SSH_AGENT_PID SSH_AUTH_SOCK=$(cat "$STORE_PATH/sock") export SSH_AUTH_SOCK else eval "$(ssh-agent)" > /dev/null echo "$SSH_AGENT_PID" > "$STORE_PATH"/id echo "$SSH_AUTH_SOCK" > "$STORE_PATH"/sock fi fi ``` -------------------------------- ### Simple Static Site Deployment Pattern Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/rsync-integration.md Configuration for deploying a simple static site. It synchronizes the current directory (`./`) to the remote path `/var/www/html/` with archive, verbose, recursive, and delete options, excluding the `.git/` directory. ```yaml with: switches: -avzr --delete --exclude='.git/' path: ./ remote_path: /var/www/html/ ``` -------------------------------- ### Basic Deployment to Production Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/README.md Use this snippet for a standard deployment to a production environment. Ensure sensitive details are stored in GitHub Secrets. ```yaml - uses: burnett01/rsync-deployments@v8 with: switches: -avzr --delete path: dist/ remote_path: /var/www/app/ remote_host: ${{ secrets.PROD_HOST }} remote_user: ${{ secrets.PROD_USER }} remote_key: ${{ secrets.PROD_KEY }} ``` -------------------------------- ### Rsync Deployment in Debug Mode Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/action-inputs.md Enable debug mode for the rsync deployment to get more verbose output, which can be helpful for troubleshooting. ```yaml - name: Deploy via rsync (with debug) uses: burnett01/rsync-deployments@v8 with: debug: "true" switches: -avzr --delete path: src/ remote_path: /var/www/html/ remote_host: example.com remote_user: ubuntu remote_key: ${{ secrets.DEPLOY_KEY }} ``` -------------------------------- ### Template for a New BATS Test Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/testing-reference.md A structured template for writing new BATS tests, including setup, execution, and assertion steps. ```bats @test "description of what is tested" { # 1. Set up environment export INPUT_SOME_VAR="value" # 2. Create any necessary mock files or directories touch somefile # 3. Run the script run ./entrypoint.sh # 4. Assert results [ "$status" -eq 0 ] # Check exit code [[ "${output}" == *"expected output"* ]] # Check output [ -f "expected_file" ] # Check file exists # 5. Clean up in teardown (not in test) } ``` -------------------------------- ### Source SSH Initialization Scripts Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/entrypoint-execution.md Sources helper scripts to initialize the SSH environment. 'ssh-init' creates the .ssh directory, and 'hosts-init' manages the known_hosts file. ```sh source ssh-init ``` ```sh source hosts-init ``` -------------------------------- ### BATS Test Teardown Phase Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/testing-reference.md Shows the teardown phase in a BATS test, responsible for cleaning up mock files created during the setup phase. ```bats teardown() { rm -f source agent-start agent-add rsync ssh-keyscan hosts-add } ``` -------------------------------- ### SSH Agent Kill Command Example Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/helper-scripts.md Demonstrates the use of the 'ssh-agent -k' command to terminate the SSH agent. This is used by the agent-stop script. ```shell ssh-agent -k ``` -------------------------------- ### Using rsync-deployments Action Outputs Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/deployment-workflow.md Demonstrates how to capture and use the output of the rsync-deployments action. The 'outcome' property can be accessed in subsequent steps to verify deployment success. ```yaml steps: - name: Deploy uses: burnett01/rsync-deployments@v8 id: rsync_deploy with: switches: -avzr --delete path: dist/ remote_path: /var/www/app/ remote_host: ${{ secrets.REMOTE_HOST }} remote_user: ${{ secrets.REMOTE_USER }} remote_key: ${{ secrets.REMOTE_KEY }} - name: Verify deployment run: | echo "Deployment completed with exit code: ${{ steps.rsync_deploy.outcome }}" ``` -------------------------------- ### Exclude Single Folder Source: https://github.com/burnett01/rsync-deployments/blob/master/README.md Use the --exclude switch to prevent specific files or folders from being copied. This example excludes the .git/ directory. ```yaml switches: -avzr --delete --exclude='.git/' ``` -------------------------------- ### Multi-Environment Deployment with Matrix Strategy Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/deployment-workflow.md Use this pattern to deploy to multiple environments (e.g., staging and production) automatically based on branch pushes. It leverages GitHub Actions matrix strategy to define environment-specific configurations. ```yaml name: Deploy to Multiple Environments on: push: branches: - main - staging jobs: deploy: name: Deploy runs-on: ubuntu-latest strategy: matrix: include: - branch: main environment: production host_secret: PROD_HOST user_secret: PROD_USER key_secret: PROD_KEY path: /var/www/production/ - branch: staging environment: staging host_secret: STAGING_HOST user_secret: STAGING_USER key_secret: STAGING_KEY path: /var/www/staging/ steps: - uses: actions/checkout@v4 with: ref: ${{ github.ref }} - name: Build for ${{ matrix.environment }} run: npm run build:${{ matrix.environment }} - name: Deploy to ${{ matrix.environment }} uses: burnett01/rsync-deployments@v8 with: switches: -avzr --delete path: dist/ remote_path: ${{ matrix.path }} remote_host: ${{ secrets[matrix.host_secret] }} remote_user: ${{ secrets[matrix.user_secret] }} remote_key: ${{ secrets[matrix.key_secret] }} ``` -------------------------------- ### Check Remote Server for Rsync Issues Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/troubleshooting-guide.md Perform checks on the remote server, including directory existence, permissions, disk space, and rsync installation. ```sh # SSH into remote and verify: # - Directory exists: ls -la /var/www/app/ # - Permissions correct: stat /var/www/app/ # - Disk space available: df -h # - rsync installed: which rsync ``` -------------------------------- ### Example Action Input: SSH_ASKPASS_PASSWORD Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt The password to be used by the SSH agent's askpass program. This is typically used when the SSH private key is passphrase-protected. ```yaml SSH_ASKPASS_PASSWORD: ${{ secrets.SSH_ASKPASS_PASSWORD }} ``` -------------------------------- ### Backup Before Deploy Pattern Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/rsync-integration.md Configuration to create a backup of the remote directory before deploying new files. It uses the `--backup` and `--backup-dir` rsync options to store backups with a timestamped directory. ```yaml with: switches: -avzr --delete --backup --backup-dir=../backups/$(date +%Y%m%d_%H%M%S) path: dist/ remote_path: /var/www/app/ ``` -------------------------------- ### Example Action Input: DELETE_REMOTE Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt A boolean flag to enable or disable the deletion of files on the remote server that are not present in the source directory. Defaults to 'false'. ```yaml DELETE_REMOTE: 'true' ``` -------------------------------- ### Exclude Multiple Folders and Files Source: https://github.com/burnett01/rsync-deployments/blob/master/README.md Multiple --exclude switches can be used to exclude several items. This example excludes .git/, node_modules/, and .env. ```yaml switches: -avzr --delete --exclude='.git/' --exclude='node_modules/' --exclude='.env' ``` -------------------------------- ### Manual Deployment with Environment Selection Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/deployment-workflow.md This pattern allows for manual triggering of deployments with a choice of target environment and version. It uses `workflow_dispatch` and dynamic secret referencing for flexibility. ```yaml name: Manual Deploy on: workflow_dispatch: inputs: environment: description: 'Target environment' required: true type: choice options: - staging - production version: description: 'Version to deploy' required: true jobs: deploy: name: Deploy to ${{ github.event.inputs.environment }} runs-on: ubuntu-latest environment: name: ${{ github.event.inputs.environment }} url: https://${{ secrets[format('{0}_HOST', github.event.inputs.environment)] }} steps: - uses: actions/checkout@v4 with: ref: v${{ github.event.inputs.version }} - name: Build run: npm run build - name: Deploy uses: burnett01/rsync-deployments@v8 with: switches: -avzr --delete path: dist/ remote_path: ${{ secrets[format('{0}_PATH', github.event.inputs.environment)] }} remote_host: ${{ secrets[format('{0}_HOST', github.event.inputs.environment)] }} remote_user: ${{ secrets[format('{0}_USER', github.event.inputs.environment)] }} remote_key: ${{ secrets[format('{0}_KEY', github.event.inputs.environment)] }} ``` -------------------------------- ### Example Action Input: SSH_PORT Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt The SSH port number on the remote server. Defaults to 22 if not specified. Use this if your SSH server runs on a non-standard port. ```yaml SSH_PORT: 22 ``` -------------------------------- ### Example BATS Test Case for Directory Exclusion Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/MANIFEST.txt A BATS test case to test the exclusion of a directory during rsync transfer. It ensures that specified directories are not copied. ```bash @test "directory exclusion works" { # Create a directory to be excluded mkdir -p /tmp/source/excluded_dir echo "this should not be transferred" > /tmp/source/excluded_dir/file.txt run rsync -avz --exclude 'excluded_dir/' -e "ssh -p $SSH_PORT" /tmp/source/ $SSH_USER@$SSH_HOST:$DESTINATION_DIR [ "$status" -eq 0 ] # Verify exclusion (this part would need remote check or a more complex setup) } ``` -------------------------------- ### Parallel Backend and Frontend Deployments Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/deployment-workflow.md This workflow demonstrates parallel deployment of backend and frontend applications after a build step. It uses the rsync-deployments action for each deployment target. ```yaml jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npm run build - uses: actions/upload-artifact@v3 with: name: dist path: dist/ deploy-backend: needs: build runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v3 with: name: dist - uses: burnett01/rsync-deployments@v8 with: switches: -avzr --delete path: backend/ remote_path: /var/www/api/ remote_host: ${{ secrets.BACKEND_HOST }} remote_user: ${{ secrets.REMOTE_USER }} remote_key: ${{ secrets.REMOTE_KEY }} deploy-frontend: needs: build runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v3 with: name: dist - uses: burnett01/rsync-deployments@v8 with: switches: -avzr --delete path: frontend/ remote_path: /var/www/ui/ remote_host: ${{ secrets.FRONTEND_HOST }} remote_user: ${{ secrets.REMOTE_USER }} remote_key: ${{ secrets.REMOTE_KEY }} ``` -------------------------------- ### BATS Test Execution Commands Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/testing-reference.md Shows how to execute BATS tests from the command line, including options for running all tests, specific tests, or with TAP output. ```bash bats test/entrypoint.bats # Run all tests bats test/entrypoint.bats -f "test name" # Run specific test bats test/entrypoint.bats -t # Run with TAP output ``` -------------------------------- ### Clean APK Package Cache Source: https://github.com/burnett01/rsync-deployments/blob/master/_autodocs/docker-image-reference.md Removes the Alpine package manager cache after installation to reduce the final Docker image size. This is beneficial for single-use action containers. ```dockerfile RUN rm -rf /var/cache/apk/* ```