From c0ed53e384b8e1e6fc27ab111559fcfe81969fc4 Mon Sep 17 00:00:00 2001 From: Stephen Fraser Date: Tue, 19 Oct 2021 12:11:38 +0100 Subject: [PATCH] Added docker tag publishing --- .github/workflows/docker.yaml | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index a953f84..920e86c 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -1,8 +1,11 @@ -name: Tasks API API Docker +name: Tasks API Release on: push: - branches: [main] + branches: ['main'] + tags: ['v*'] + pull_request: + branches: ['main'] paths: - ".github/workflows/docker.yaml" - "src/**" @@ -20,6 +23,12 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ghcr.io/digirati-co-uk/tasks-api + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 @@ -31,6 +40,7 @@ jobs: key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- + - name: Login to GitHub Container Registry if: github.event_name != 'pull_request' uses: docker/login-action@v1 @@ -45,9 +55,9 @@ jobs: with: builder: ${{ steps.buildx.outputs.name }} context: . - push: true - tags: | - ghcr.io/digirati-co-uk/tasks-api:${{ github.sha }} - ghcr.io/digirati-co-uk/tasks-api:latest + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file + run: echo ${{ steps.docker_build.outputs.digest }}