57 lines
1.7 KiB
YAML
57 lines
1.7 KiB
YAML
name: Build Docker Image
|
|
run-name: ${{ gitea.actor }} building ${{ gitea.ref_name }}
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- dev
|
|
- workflow
|
|
|
|
jobs:
|
|
Docker-Build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Clone Repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build docker image
|
|
run: docker build -t umbrella .
|
|
|
|
- name: Store tag date
|
|
run: |
|
|
TAG=$(date +%Y%m%d_%H%M)_${{ gitea.ref_name }}
|
|
echo $TAG > /tmp/tag
|
|
echo Using '"'$TAG'"' as tag.
|
|
|
|
- name: Tag image for upload
|
|
run: |
|
|
TAG=$(cat /tmp/tag)
|
|
docker tag umbrella ${{ secrets.REGISTRY_PATH }}/umbrella:${{ gitea.ref_name }}
|
|
docker tag umbrella ${{ secrets.REGISTRY_PATH }}/umbrella:$TAG
|
|
|
|
- name: Login to registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ secrets.REGISTRY_PATH }}
|
|
username: ${{ secrets.REGISTRY_USER }}
|
|
password: ${{ secrets.REGISTRY_PASS }}
|
|
|
|
- name: Push to registry
|
|
run: |
|
|
TAG=$(cat /tmp/tag)
|
|
docker push ${{ secrets.REGISTRY_PATH }}/umbrella:${{ gitea.ref_name }}
|
|
docker push ${{ secrets.REGISTRY_PATH }}/umbrella:$TAG
|
|
|
|
Clean-Registry:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Get tag list
|
|
run: |
|
|
TAGS="$(curl -s -u "${{ secrets.REGISTRY_USER }}:${{ secrets.REGISTRY_PASS }}" https://${{ secrets.REGISTRY_PATH }}/v2/umbrella/tags/list | jq -r ".tags[]")"
|
|
echo tags: $TAGS
|
|
COUNT=$(echo "$TAGS" | wc -l)
|
|
echo count: $COUNT
|
|
REMAIN=$((COUNT - 10))
|
|
echo remaining: $REMAIN
|
|
echo "$TAGS" | head -n $REMAIN
|