created new step to delete old containers and imagess
Build and Push Image / build-and-push (push) Successful in 1m20s

This commit is contained in:
2026-05-02 22:19:43 -07:00
parent 9b2582bb3f
commit ce232fe3f8
+14 -6
View File
@@ -1,25 +1,33 @@
name: Build and Push Image
on: [push]
jobs:
build-and-push:
runs-on: ubuntu-latest
# Required for building containers inside a containerized runner
container:
image: catthehacker/ubuntu:act-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Log in to Gitea Registry
uses: docker/login-action@v2
with:
registry: gitea.nelson-household.com # Replace with your Gitea domain
username: ${{ gitea.actor }}
password: ${{ secrets.RUNNER_TOKEN }}
- name: Delete Old Images and Containers
run: |
CONTAINERS=$(docker ps -aqf "reference=gitea\.nelson-household\.com\/joseph\.nelson4456\/koillection-uploader\/koilcollection-uploader" || true)
IMAGES=$(docker images --filter "reference=gitea\.nelson-household\.com\/joseph\.nelson4456\/koillection-uploader\/koilcollection-uploader" -q)
if [ ! -z "$CONTAINERS" ]; then
echo "Deleting Containers:"
docker rm $CONTAINERS
fi
if [ ! -z "$IMAGES" ]; then
echo "Deleting Images:"
docker rmi $IMAGES
fi
- name: Build and Push Image
run: |
docker build -t gitea.nelson-household.com/joseph.nelson4456/koillection-uploader/koillection-uploader:${{ github.sha }} .
docker push gitea.nelson-household.com/joseph.nelson4456/koillection-uploader/koillection-uploader:${{ github.sha }}
docker build -t gitea.nelson-household.com/joseph.nelson4456/koillection-uploader/koilcollection-uploader:${{ github.sha }} .
docker push gitea.nelson-household.com/joseph.nelson4456/koillection-uploader/koilcollection-uploader:${{ github.sha }}