Skip to content

Commit c5cc9c3

Browse files
authored
Update droplet deployment script (#33)
1 parent d7f91a2 commit c5cc9c3

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

.github/workflows/docker_container_deploy.yml

+16-6
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,21 @@ jobs:
2727
username: ${{ secrets.DROPLET_USERNAME }}
2828
key: ${{ secrets.DROPLET_KEY }}
2929
script: |
30-
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
31-
if [ -s /tmp/current_container_id ]; then # Check if previous container exists and is running
32-
docker stop $(cat /tmp/current_container_id) || true # Stop the old container
33-
docker rm $(cat /tmp/current_container_id) || true # Remove the old container
30+
# Check if previous container exists and is running (based on name)
31+
existing_container_id=$(docker ps -aqf "name=$container_name")
32+
if [ -n "$existing_container_id" ]; then
33+
echo "Stopping existing container: $container_name"
34+
docker stop $existing_container_id
35+
docker rm $existing_container_id
3436
fi
3537
36-
docker pull ghcr.io/trumpee/trumpee-${{ env.lowercase_repo_name }}:${{ github.event.release.tag_name}}
37-
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}}
38+
# Pull with explicit tag (or default to 'latest')
39+
echo "Pulling image: ghcr.io/trumpee/trumpee-${{ env.lowercase_repo_name }}:${{ github.event.release.tag_name}}"
40+
docker pull "ghcr.io/trumpee/trumpee-${{ env.lowercase_repo_name }}:${{ github.event.release.tag_name}}"
41+
42+
# Run with the specified tag, restart policy, and optional ports
43+
echo "Running container: trumpee-${{ env.lowercase_repo_name }}:${{ github.event.inputs.image_tag }}"
44+
docker run -d \
45+
--restart unless-stopped \
46+
--name "trumpee-${{ env.lowercase_repo_name }}:${{ github.event.inputs.image_tag }}" \
47+
"ghcr.io/trumpee/trumpee-${{ env.lowercase_repo_name }}:${{ github.event.release.tag_name}}"

0 commit comments

Comments
 (0)