created new step to delete old containers and imagess
Build and Push Image / build-and-push (push) Successful in 1m20s
Build and Push Image / build-and-push (push) Successful in 1m20s
This commit is contained in:
@@ -1,25 +1,33 @@
|
|||||||
name: Build and Push Image
|
name: Build and Push Image
|
||||||
on: [push]
|
on: [push]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Required for building containers inside a containerized runner
|
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Log in to Gitea Registry
|
- name: Log in to Gitea Registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: gitea.nelson-household.com # Replace with your Gitea domain
|
registry: gitea.nelson-household.com # Replace with your Gitea domain
|
||||||
username: ${{ gitea.actor }}
|
username: ${{ gitea.actor }}
|
||||||
password: ${{ secrets.RUNNER_TOKEN }}
|
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
|
- name: Build and Push Image
|
||||||
run: |
|
run: |
|
||||||
docker build -t 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/koillection-uploader:${{ github.sha }}
|
docker push gitea.nelson-household.com/joseph.nelson4456/koillection-uploader/koilcollection-uploader:${{ github.sha }}
|
||||||
|
|||||||
Reference in New Issue
Block a user