Skip to content

Commit

Permalink
added step to remove old images and containers at once
Browse files Browse the repository at this point in the history
  • Loading branch information
kaxada committed Dec 26, 2023
1 parent af919ba commit 7988830
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Remove old Docker images
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 }}
docker images --filter "reference=${{ env.IMAGE_NAME }}*" -q | xargs docker rmi -f || true
fi
- name: Build Docker image
run: docker build -t ${{ env.IMAGE_NAME }}:${{ github.sha }} .

Expand All @@ -35,10 +48,6 @@ jobs:
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 }} \
Expand Down

0 comments on commit 7988830

Please sign in to comment.