From aa552cf90fc649bc79e1f47c84090065cd2e55de Mon Sep 17 00:00:00 2001 From: Ariel Gentile Date: Tue, 19 Mar 2024 18:53:03 -0300 Subject: [PATCH] ci: use semantic-release plugin for docker --- .github/workflows/cd.yml | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index e5d5c95..c336ccd 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -6,11 +6,6 @@ on: workflow_dispatch: -env: - DH_USERNAME: ${{secrets.DOCKER_HUB_LOGIN}} - DH_TOKEN: ${{secrets.DOCKER_HUB_PWD}} - IMAGE_NAME: '2060-service-agent' - jobs: build: runs-on: ubuntu-latest @@ -64,20 +59,27 @@ jobs: } ], "@semantic-release/release-notes-generator", + [ + "@codedependant/semantic-release-docker", + { + "dockerTags": + [ + "${RELEASE_MAJOR}-${GITHUB_REF##*/}", + "${RELEASE_MAJOR}.${RELEASE_MINOR}-${GITHUB_REF##*/}", + "${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_PATCH}-${GITHUB_REF##*/}", + "$RELEASE_VERSION", + "${GITHUB_REF##*/}" + ], + "dockerImage": "${IMAGE_NAME}" + } + ] ] + additional-packages: | + ['@codedependant/semantic-release-docker'] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_REGISTRY_USER: ${{ secrets.DOCKER_HUB_LOGIN }} + DOCKER_REGISTRY_PASSWORD : ${{ secrets.DOCKER_HUB_PWD }} + IMAGE_NAME: '2060-service-agent' - run: echo ${{ steps.semantic.outputs.release-version }} - - - name: Log in to Docker Hub - run: | - echo "$DH_TOKEN" | docker login -u "$DH_USERNAME" --password-stdin - - - name: Build Docker image - run: | - docker build -f Dockerfile -t $DH_USERNAME/$IMAGE_NAME:$RELEASE_VERSION-${GITHUB_REF##*/} . - - - name: Push Docker image to Docker Hub - run: | - docker push $DH_USERNAME/$IMAGE_NAME:$RELEASE_VERSION-${GITHUB_REF##*/}