trigger_deployment #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Docker Image | |
on: | |
workflow_dispatch: | |
repository_dispatch: | |
types: [trigger_deployment] | |
env: | |
IMAGE_NAME: ghcr.io/dulliag/dulli-bot | |
jobs: | |
renew_docker_compose: | |
name: Rebuild Remote Docker-Compose | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Connect and deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.RS1_HOST }} | |
username: ${{ secrets.RS1_USER }} | |
password: ${{ secrets.RS1_PASSWORD }} | |
port: 22 | |
script: | | |
echo ${{ secrets.NPM_TOKEN }} | docker login ghcr.io -u ${{ secrets.DOCKER_USER }} --password-stdin | |
CONTAINER_NAME="dullibot" | |
if [ "$(docker ps -a --filter "name=$CONTAINER_NAME" --format '{{.Names}}')" ]; then | |
docker container stop $CONTAINER_NAME | |
docker container rm -f $CONTAINER_NAME | |
fi | |
if [ "$(docker images -q "${{ env.IMAGE_NAME }}:latest")" ]; then | |
docker rmi "${{ env.IMAGE_NAME }}:latest" | |
fi | |
docker pull ${{ env.IMAGE_NAME }}:latest | |
docker run -itd --env-file '${{ secrets.RS1_REMOTE_LOCATION }}/dullibot.env' --restart on-failure:3 --name=$CONTAINER_NAME ${{ env.IMAGE_NAME }}:latest |