Skip to content

Commit

Permalink
Merge pull request #18 from mehedikhan72/playing-with-ci-cd
Browse files Browse the repository at this point in the history
update build n deploy
  • Loading branch information
mehedikhan72 authored Aug 25, 2024
2 parents c530669 + 74e9aea commit 0d65308
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@ jobs:
script: |
# Login to registry
docker login -u ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} -p ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} registry.digitalocean.com
# Stop running container
docker stop $(echo $IMAGE_NAME)
# Remove old container
docker rm $(echo $IMAGE_NAME)
# Stop and remove old container if it exists
if [ "$(docker ps -q -f name=$(echo $IMAGE_NAME))" ]; then
docker stop $(echo $IMAGE_NAME)
docker rm $(echo $IMAGE_NAME)
fi
# Run a new container from a new image
docker run -d \
--restart always \
--name $(echo $IMAGE_NAME) \
$(echo $REGISTRY)/$(echo $IMAGE_NAME):$(echo $GITHUB_SHA | head -c7)
--restart always \
--name $(echo $IMAGE_NAME) \
-p 8080:8080 \
$(echo $REGISTRY)/$(echo $IMAGE_NAME):$(echo $GITHUB_SHA | head -c7)

0 comments on commit 0d65308

Please sign in to comment.