Skip to content

Commit

Permalink
Add container deployment parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Bardin08 committed May 18, 2024
1 parent 51c433e commit 0cd7794
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/docker_container_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy to DROPLET

on:
workflow_dispatch:
inputs:
image_tag:
description: 'Choose a tag:'
required: true
type: string
default: 'latest'

jobs:
deploy:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Convert Repository Name to Lowercase
run: |
lowercase_name=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
echo "lowercase_repo_name=$lowercase_name" >> $GITHUB_ENV
- name: Deploy infra to DROPLET
uses: appleboy/ssh-action@master
with:
passphrase: ${{ secrets.SSH_PASSPHRASE }}
host: ${{ secrets.DROPLET_HOST }}
username: ${{ secrets.DROPLET_USERNAME }}
key: ${{ secrets.DROPLET_KEY }}
script: |
docker container ls -q --filter name=trumpee-${{ env.lowercase_repo_name }}:${{ github.event.inputs.image_tag }} > /tmp/current_container_id || true # Get the container ID if it exists
if [ -s /tmp/current_container_id ]; then # Check if previous container exists and is running
docker stop $(cat /tmp/current_container_id) || true # Stop the old container
docker rm $(cat /tmp/current_container_id) || true # Remove the old container
fi
docker pull ghcr.io/trumpee/trumpee-${{ env.lowercase_repo_name }}:${{ github.event.release.tag_name}}
docker run -d -p 5217:8080 --name trumpee-${{ env.lowercase_repo_name }}:${{ github.event.inputs.image_tag }} ghcr.io/trumpee/trumpee-${{ env.lowercase_repo_name }}:${{ github.event.release.tag_name}}

0 comments on commit 0cd7794

Please sign in to comment.