11name : Build and push cinder image
22
33on :
4- release :
5- types :
6- - published
4+ push :
5+ # Sequence of patterns matched against refs/tags
6+ tags :
7+ - ' v*' # Push events to matching v*, i.e. v1.0, v20.15.10
78
89jobs :
9- lint-test :
10+ push :
1011 runs-on : ubuntu-latest
1112 steps :
1213 - name : Checkout
@@ -22,19 +23,52 @@ jobs:
2223 - name : Install helm
2324 run : curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
2425
25- - name : Login to DockerHub Registry
26- run : echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
26+ - name : Prepare
27+ id : prep
28+ run : |
29+ DOCKER_IMAGE=${GITHUB_REPOSITORY}
30+ VERSION=noop
31+ if [ "${{ github.event_name }}" = "schedule" ]; then
32+ VERSION=nightly
33+ elif [[ $GITHUB_REF == refs/tags/* ]]; then
34+ VERSION=${GITHUB_REF#refs/tags/}
35+ elif [[ $GITHUB_REF == refs/heads/* ]]; then
36+ VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
37+ if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
38+ VERSION=edge
39+ fi
40+ elif [[ $GITHUB_REF == refs/pull/* ]]; then
41+ VERSION=pr-${{ github.event.number }}
42+ fi
43+ TAGS="${DOCKER_IMAGE}:${VERSION}"
44+ if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
45+ MINOR=${VERSION%.*}
46+ MAJOR=${MINOR%.*}
47+ TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
48+ elif [ "${{ github.event_name }}" = "push" ]; then
49+ TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
50+ fi
51+ echo ::set-output name=version::${VERSION}
52+ echo ::set-output name=tags::${TAGS}
53+ echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
2754
28- - name : Get the version
29- id : vars
30- run : echo ::set-output name=tag::$(echo ${GITHUB_REF:10})
55+ - name : Login to DockerHub
56+ uses : docker/login-action@v1
57+ with :
58+ username : ${{ secrets.DOCKERHUB_USERNAME }}
59+ password : ${{ secrets.DOCKERHUB_TOKEN }}
3160
3261 - name : Build the cinder image
3362 run : |
34- export TAG=${{steps.vars .outputs.tag }}
63+ export TAG=${{steps.prep .outputs.version }}
3564 cd build/images/node
3665 make build
3766
3867 - name : Push the cinder image
3968 run : |
40- docker push docker.io/criticalstack/cinder:${{steps.vars.outputs.tag}}
69+ IFS=, read -ra values <<< "${{steps.prep.outputs.tags}}"
70+ for img in ${values[@]}
71+ do
72+ docker tag criticalstack/cinder:${{steps.prep.outputs.version}} $img
73+ docker push $img
74+ done
0 commit comments