Skip to content

Commit

Permalink
testing docker deploys
Browse files Browse the repository at this point in the history
  • Loading branch information
kaxada committed Dec 24, 2023
1 parent d4aa25f commit e803a10
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI/CD

on:
push:
branches:
- "develop"

env:
IMAGE_NAME: "project_badging"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build Docker image
run: docker build -t ${{ env.IMAGE_NAME }}:${{ github.sha }} .

- name: Create image archive
run: docker save ${{ env.IMAGE_NAME }}:${{ github.sha }} -o badging.tar

- name: Upload image archive using appleboy/scp-action
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
source: badging.tar
target: ~/

- name: Extract and load image on droplet
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
if docker inspect ${{ env.IMAGE_NAME }} >/dev/null 2>&1; then
docker stop ${{ env.IMAGE_NAME }}
docker rm ${{ env.IMAGE_NAME }}
fi
docker load -i ~/badging.tar
docker run -d \
-p ${{ secrets.PORT }}:${{ secrets.PORT }} \
--env-file /home/${{ secrets.USERNAME }}/.env \
--restart=always \
--name ${{ env.IMAGE_NAME }} \
${{ env.IMAGE_NAME }}:${{ github.sha }}

0 comments on commit e803a10

Please sign in to comment.