From 4b59e434e3db2d24d04163ae5391b92f26edf29f Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Wed, 13 Oct 2021 10:51:27 -0400 Subject: [PATCH] Create tagged image when publishing a release (#43) Signed-off-by: Nicko Guyer --- .github/workflows/docker.yml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index cfe2281..ad65990 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,9 +1,8 @@ name: Docker on: - push: - branches: - - main + release: + types: [published, prereleased] jobs: docker: @@ -12,9 +11,19 @@ jobs: - uses: actions/checkout@v2 - name: Build - run: docker build -t ghcr.io/hyperledger/firefly-dataexchange-https:latest . - - - name: Push + run: docker build -t ghcr.io/hyperledger/firefly-dataexchange-https:${GITHUB_REF##*/} . + + - name: Tag release + if: github.event.action == 'published' + run: docker tag ghcr.io/hyperledger/firefly-dataexchange-https:${GITHUB_REF##*/} ghcr.io/hyperledger/firefly-dataexchange-https:latest + + - name: Push docker image + run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin + docker push ghcr.io/hyperledger/firefly-dataexchange-https:${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-dataexchange-https:latest + docker push ghcr.io/hyperledger/firefly-dataexchange-https:latest \ No newline at end of file