34 lines
1.4 KiB
YAML
34 lines
1.4 KiB
YAML
name: Build and Push Image
|
|
on: [push]
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
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/koilcollection-uploader:${{ github.sha }} .
|
|
docker push gitea.nelson-household.com/joseph.nelson4456/koillection-uploader/koilcollection-uploader:${{ github.sha }}
|