File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ unknown docker-images. It is entirely built from Dockerfile on top of
2020 container will have this prefix in name.
2121 * ` docker_compose_filename ` - Path to the docker-compose file in the repository.
2222 * ` use_stack ` - Use docker stack instead of docker-compose.
23+ * ` docker_compose_down ` - Execute docker-compose-down.
2324
2425# Usage example
2526
@@ -124,3 +125,28 @@ jobs:
124125 use_stack: 'true'
125126```
126127
128+ # Down deploy (Docker-compose down)
129+ If you need to run a docker-compose down to do a clean rollback. Only one down of the
130+ services will be executed To do that just set ` docker_compose_down ` input to ` "true" ` :
131+ ```
132+ name: Deploy
133+ on:
134+ push:
135+ branches: [ master ]
136+
137+ jobs:
138+ deploy:
139+ runs-on: ubuntu-latest
140+
141+ steps:
142+ - actions/chockout@v2
143+
144+ - uses: alex-ac/github-action-ssh-docker-compose@master
145+ name: Docker-Stack Remote Deployment
146+ with:
147+ ssh_host: example.com
148+ ssh_private_key: ${{ secrets.EXAMPLE_COM_SSH_PRIVATE_KEY }}
149+ ssh_user: ${{ secrets.EXAMPLE_COM_SSH_USER }}
150+ docker_compose_prefix: example.com
151+ docker_compose_down: 'true'
152+ ```
Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ inputs:
2323 use_stack :
2424 description : Use docker stack instead of docker compose ("true" or "false").
2525 default : ' false'
26+ docker_compose_down :
27+ description : Execute docker-compose-down ("true" or "false").
28+ default : ' false'
2629runs :
2730 using : docker
2831 image : Dockerfile
3437 DOCKER_COMPOSE_FILENAME : ${{ inputs.docker_compose_filename }}
3538 DOCKER_COMPOSE_PREFIX : ${{ inputs.docker_compose_prefix }}
3639 USE_DOCKER_STACK : ${{ inputs.use_stack }}
40+ DOCKER_COMPOSE_DOWN : ${{ inputs.docker_compose_down }}
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ remote_command="set -e ; log() { echo '>> [remote]' \$@ ; } ; cleanup() { log 'R
2424if $USE_DOCKER_STACK ; then
2525 remote_command=" set -e ; log() { echo '>> [remote]' \$ @ ; } ; cleanup() { log 'Removing workspace...'; rm -rf \"\$ HOME/workspace\" ; } ; log 'Creating workspace directory...' ; mkdir -p \"\$ HOME/workspace/$DOCKER_COMPOSE_PREFIX \" ; trap cleanup EXIT ; log 'Unpacking workspace...' ; tar -C \"\$ HOME/workspace/$DOCKER_COMPOSE_PREFIX \" -xjv ; log 'Launching docker stack deploy...' ; cd \"\$ HOME/workspace/$DOCKER_COMPOSE_PREFIX \" ; docker stack deploy -c \" $DOCKER_COMPOSE_FILENAME \" --prune \" $DOCKER_COMPOSE_PREFIX \" "
2626fi
27+ if $DOCKER_COMPOSE_DOWN ; then
28+ remote_command=" set -e ; log() { echo '>> [remote]' \$ @ ; } ; cleanup() { log 'Removing workspace...'; rm -rf \"\$ HOME/workspace\" ; } ; log 'Creating workspace directory...' ; mkdir -p \"\$ HOME/workspace\" ; trap cleanup EXIT ; log 'Unpacking workspace...' ; tar -C \"\$ HOME/workspace\" -xjv ; log 'Launching docker-compose...' ; cd \"\$ HOME/workspace\" ; docker-compose -f \" $DOCKER_COMPOSE_FILENAME \" -p \" $DOCKER_COMPOSE_PREFIX \" down"
29+ fi
2730
2831ssh-add <( echo " $SSH_PRIVATE_KEY " )
2932
You can’t perform that action at this time.
0 commit comments