7777 name : artifact-linux-docker
7878 path : app.tar.gz
7979
80-
8180 cicd-docker :
8281 name : CICD Docker
8382 runs-on : ubuntu-latest
@@ -91,11 +90,39 @@ jobs:
9190 - name : Extract app archive
9291 run : tar -zxvf app.tar.gz
9392
94- - name : Docker build and publish
95- uses : docker/build-push-action@v1
93+ - name : Prepare
94+ id : prep
95+ run : |
96+ DOCKER_IMAGE=sakadream/actix-web-rest-api-with-jwt
97+ VERSION=edge
98+ if [[ $GITHUB_REF == refs/tags/* ]]; then
99+ VERSION=${GITHUB_REF#refs/tags/}
100+ elif [[ $GITHUB_REF == refs/heads/* ]]; then
101+ VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
102+ elif [[ $GITHUB_REF == refs/pull/* ]]; then
103+ VERSION=pr-${{ github.event.number }}
104+ fi
105+ TAGS="${DOCKER_IMAGE}:${VERSION}"
106+ if [ "${{ github.event_name }}" = "push" ]; then
107+ TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
108+ fi
109+ echo ::set-output name=version::${VERSION}
110+ echo ::set-output name=tags::${TAGS}
111+ echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
112+
113+ - name : Login to DockerHub
114+ uses : docker/login-action@v1
96115 with :
97116 username : ${{ secrets.DOCKER_USERNAME }}
98117 password : ${{ secrets.DOCKER_PASSWORD }}
99- repository : sakadream/actix-web-rest-api-with-jwt
100- add_git_labels : true
101- tag_with_ref : true
118+
119+ - name : Docker build and publish
120+ uses : docker/build-push-action@v2
121+ with :
122+ context : .
123+ file : ./Dockerfile
124+ tags : ${{ steps.prep.outputs.tags }}
125+ labels : |
126+ org.opencontainers.image.source=${{ github.event.repository.html_url }}
127+ org.opencontainers.image.created=${{ steps.prep.outputs.created }}
128+ org.opencontainers.image.revision=${{ github.sha }}
0 commit comments