From 1ec164924d1cdf2af27585dd83126f90746c6e5a Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 11 Oct 2021 14:19:59 -0400 Subject: [PATCH 1/4] Create tagged image when publishing a release Signed-off-by: Nicko Guyer --- .github/workflows/docker.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f414a963..e211ab5e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,6 +4,9 @@ on: push: branches: - main + release: + types: + - published jobs: docker: @@ -13,8 +16,12 @@ jobs: - name: Build run: docker build -t ghcr.io/hyperledger/firefly-ethconnect:latest . - - - name: Push + + - name: Tag release + if: github.event_name == 'release' && github.event.action == 'published' + run: docker tag ghcr.io/hyperledger/firefly-ethconnect:latest ghcr.io/hyperledger/firefly-ethconnect:$GITHUB_REF + + - name: Push docker image run: | echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin - docker push ghcr.io/hyperledger/firefly-ethconnect:latest + docker push -a ghcr.io/hyperledger/firefly-ethconnect \ No newline at end of file From 0a77fdf48c48cc892cde79609601a3caa47b515f Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 11 Oct 2021 14:59:26 -0400 Subject: [PATCH 2/4] Only build docker images on releases Signed-off-by: Nicko Guyer --- .github/workflows/docker.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e211ab5e..754536b4 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,9 +1,6 @@ name: Docker on: - push: - branches: - - main release: types: - published @@ -18,7 +15,6 @@ jobs: run: docker build -t ghcr.io/hyperledger/firefly-ethconnect:latest . - name: Tag release - if: github.event_name == 'release' && github.event.action == 'published' run: docker tag ghcr.io/hyperledger/firefly-ethconnect:latest ghcr.io/hyperledger/firefly-ethconnect:$GITHUB_REF - name: Push docker image From 82f6ded698ae4a86b30cfcdb9f94e5cf293bbdca Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 11 Oct 2021 15:42:53 -0400 Subject: [PATCH 3/4] Do not update latest docker tag for pre-releases Signed-off-by: Nicko Guyer --- .github/workflows/docker.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 754536b4..27e15b9f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,7 +3,7 @@ name: Docker on: release: types: - - published + - [published, prereleased] jobs: docker: @@ -12,10 +12,11 @@ jobs: - uses: actions/checkout@v2 - name: Build - run: docker build -t ghcr.io/hyperledger/firefly-ethconnect:latest . + run: docker build -t ghcr.io/hyperledger/firefly-ethconnect:$GITHUB_REF . - name: Tag release - run: docker tag ghcr.io/hyperledger/firefly-ethconnect:latest ghcr.io/hyperledger/firefly-ethconnect:$GITHUB_REF + if: github.event.action == 'published' + run: docker tag ghcr.io/hyperledger/firefly-ethconnect:latest ghcr.io/hyperledger/firefly-ethconnect:latest - name: Push docker image run: | From 187a3eb490c92528db5c8cf9e2804771a9a38d53 Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 11 Oct 2021 15:50:06 -0400 Subject: [PATCH 4/4] Remove -a flag from docker push Signed-off-by: Nicko Guyer --- .github/workflows/docker.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 27e15b9f..8e1ce886 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -21,4 +21,10 @@ jobs: - name: Push docker image run: | echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin - docker push -a ghcr.io/hyperledger/firefly-ethconnect \ No newline at end of file + docker push ghcr.io/hyperledger/firefly-ethconnect:$GITHUB_REF + + - name: Push latest tag + if: github.event.action == 'published' + run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin + docker push ghcr.io/hyperledger/firefly-ethconnect:$latest \ No newline at end of file