Skip to content

Commit

Permalink
Deploy to Digital Ocean registry
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelKostyuk committed Feb 5, 2024
1 parent c47b3db commit 2a1e7e8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
31 changes: 1 addition & 30 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,35 +77,6 @@ jobs:

- name: Push Docker image to Docker Hub
run: |
echo ${{ secrets.DOCKER_HUB_PAT }} | docker login -u pavelkostyuk --password-stdin
echo ${{ secrets.DIGITALOCEAN_API_TOKEN }} | docker login -u pavelkostyuk --password-stdin
docker push pavelkostyuk/portfolio
deploy_to_Docker_on_VM:
needs: build_test_push_image
runs-on: ubuntu-latest
steps:
- name: SSH into Droplet and manage Docker container
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
DROPLET_IP_ADDRESS: ${{ secrets.DROPLET_IP_ADDRESS }}
run: |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ssh_key.pem
chmod 600 ssh_key.pem
ssh -o StrictHostKeyChecking=no -i ./ssh_key.pem serveradmin@${DROPLET_IP_ADDRESS} '
OLD_IMAGE_ID=$(docker images -q pavelkostyuk/portfolio:latest)
CONTAINER_ID=$(docker ps -aqf "ancestor=pavelkostyuk/portfolio")
if [ -n "$CONTAINER_ID" ]; then
docker stop $CONTAINER_ID
docker rm $CONTAINER_ID
else
echo "No container found matching the criteria."
fi
if [ -n "$OLD_IMAGE_ID" ]; then
docker rmi -f $OLD_IMAGE_ID
else
echo "No old image found matching the criteria."
fi
docker pull pavelkostyuk/portfolio:latest
docker run -d -p 8000:8000 pavelkostyuk/portfolio:latest
'
21 changes: 21 additions & 0 deletions Kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: portfolio
spec:
replicas: 1
selector:
matchLabels:
app: portfolio
template:
metadata:
labels:
app: portfolio
spec:
containers:
- name: your-container-name
image: pavelkostyuk/portfolio:latest
ports:
- containerPort: 8000
imagePullSecrets:
- name: DOCKER_HUB_PAT

0 comments on commit 2a1e7e8

Please sign in to comment.