Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update droplet deployment script #33

Merged
merged 3 commits into from
May 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .github/workflows/docker_container_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,21 @@ jobs:
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
# Check if previous container exists and is running (based on name)
existing_container_id=$(docker ps -aqf "name=$container_name")
if [ -n "$existing_container_id" ]; then
echo "Stopping existing container: $container_name"
docker stop $existing_container_id
docker rm $existing_container_id
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}}
# Pull with explicit tag (or default to 'latest')
echo "Pulling image: ghcr.io/trumpee/trumpee-${{ env.lowercase_repo_name }}:${{ github.event.release.tag_name}}"
docker pull "ghcr.io/trumpee/trumpee-${{ env.lowercase_repo_name }}:${{ github.event.release.tag_name}}"

# Run with the specified tag, restart policy, and optional ports
echo "Running container: trumpee-${{ env.lowercase_repo_name }}:${{ github.event.inputs.image_tag }}"
docker run -d \
--restart unless-stopped \
--name "trumpee-${{ env.lowercase_repo_name }}:${{ github.event.inputs.image_tag }}" \
"ghcr.io/trumpee/trumpee-${{ env.lowercase_repo_name }}:${{ github.event.release.tag_name}}"
Loading