@@ -0,0 +1,35 @@
|
|||||||
|
name: cicd
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
#paths:
|
||||||
|
#- '/**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
name: ci
|
||||||
|
runs-on: dind
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: ci
|
||||||
|
run: |
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
repo=$(grep url .git/config | awk '{print $NF}' | sed 's#.*\.[a-z]*/##' | sed 's#.git$##')
|
||||||
|
test -n "$repo"
|
||||||
|
if [[ "$repo" == *"template" ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
img=registry-app.inhome.blapointe.com:5001/"$repo":"${1:-$(date +%Y%m%d%H%M)}"
|
||||||
|
was=$((docker inspect $img | jq -r .[0].Id | sed 's/^sha256://') || true)
|
||||||
|
docker build -f ./Dockerfile -t $img .
|
||||||
|
now=$(docker inspect $img | jq -r .[0].Id | sed 's/^sha256://')
|
||||||
|
docker push $img
|
||||||
|
if [ -n "$was" ] && [ "$was" != "null" ] && [ "$was" != "$now" ] && docker inspect "$was" &> /dev/null; then
|
||||||
|
docker rmi "$was" || true
|
||||||
|
docker rmi $(docker ps | grep ${img%:*} | grep '<none>' | awk '{print $3}') || true
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user