diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 428a1c2..217cb62 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: with: fetch-depth: 1 - name: Start Deployment - uses: wshihadeh/docker-deployment-action@master + uses: gonzalochief/docker-deployment-action@master with: remote_docker_host: ${{ secrets.HOST }} ssh_private_key: ${{ secrets.PRIVATE_KEY }} @@ -29,7 +29,7 @@ jobs: args: -p test up -d - name: Start Deployment without copy - uses: wshihadeh/docker-deployment-action@master + uses: gonzalochief/docker-deployment-action@master with: remote_docker_host: ${{ secrets.HOST }} ssh_private_key: ${{ secrets.PRIVATE_KEY }} diff --git a/README.md b/README.md index ae9abe7..f90a1f9 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Below is a brief example on how the action can be used: ```yaml - name: Deploy to Docker swarm - uses: wshihadeh/docker-deployment-action@v1 + uses: gonzalochief/docker-deployment-action@v1 with: remote_docker_host: user@myswarm.com ssh_private_key: ${{ secrets.DOCKER_SSH_PRIVATE_KEY }} diff --git a/action.yml b/action.yml index 01ae3bb..408b01d 100644 --- a/action.yml +++ b/action.yml @@ -21,6 +21,9 @@ inputs: deployment_mode: description: Deployment mode either docker-swarm or docker-compose. Default is docker-compose. required: false + docker_compose_ver: + description: Docker-compose version. Default is v2. + required: false copy_stack_file: description: Copy stack file to remote server and deploy from the server. Default is false. required: false diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index adf9f6f..776288f 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -49,6 +49,7 @@ fi STACK_FILE=${INPUT_STACK_FILE_NAME} DEPLOYMENT_COMMAND_OPTIONS="" +DOCKER_COMP_COMMAND="" if [ "$INPUT_COPY_STACK_FILE" == "true" ]; then @@ -57,6 +58,15 @@ else DEPLOYMENT_COMMAND_OPTIONS=" --log-level debug --host ssh://$INPUT_REMOTE_DOCKER_HOST:$INPUT_REMOTE_DOCKER_PORT" fi +if [ "$INPUT_DEPLOYMENT_MODE" == "docker-compose" ] && [ "$INPUT_DOCKER_COMPOSE_VER" == "v2" ]; then + DOCKER_COMP_COMMAND="docker compose" +elif [ "$INPUT_DEPLOYMENT_MODE" == "docker-compose" ] && [ "$INPUT_DOCKER_COMPOSE_VER" == "v1" ]; then + DOCKER_COMP_COMMAND="docker-compose" +else + DOCKER_COMP_COMMAND="docker compose" +fi + + case $INPUT_DEPLOYMENT_MODE in docker-swarm) @@ -65,7 +75,7 @@ case $INPUT_DEPLOYMENT_MODE in *) INPUT_DEPLOYMENT_MODE="docker-compose" - DEPLOYMENT_COMMAND="docker-compose $DEPLOYMENT_COMMAND_OPTIONS -f $STACK_FILE" + DEPLOYMENT_COMMAND="$DOCKER_COMP_COMMAND $DEPLOYMENT_COMMAND_OPTIONS -f $STACK_FILE" ;; esac @@ -102,7 +112,7 @@ if ! [ -z "$INPUT_COPY_STACK_FILE" ] && [ $INPUT_COPY_STACK_FILE = 'true' ] ; th execute_ssh "ls -t $INPUT_DEPLOY_PATH/stacks/docker-stack-* 2>/dev/null | tail -n +$INPUT_KEEP_FILES | xargs rm -- 2>/dev/null || true" if ! [ -z "$INPUT_PULL_IMAGES_FIRST" ] && [ $INPUT_PULL_IMAGES_FIRST = 'true' ] && [ $INPUT_DEPLOYMENT_MODE = 'docker-compose' ] ; then - execute_ssh "${DEPLOYMENT_COMMAND} pull" + execute_ssh ${DEPLOYMENT_COMMAND} "pull" fi if ! [ -z "$INPUT_PRE_DEPLOYMENT_COMMAND_ARGS" ] && [ $INPUT_DEPLOYMENT_MODE = 'docker-compose' ] ; then