Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix image tags for main branch #13

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ on:
env:
DH_USERNAME: ${{secrets.DOCKER_HUB_LOGIN}}
DH_TOKEN: ${{secrets.DOCKER_HUB_PWD}}
IMAGE_NAME: '2060-service-agent'
IMAGE_NAME: '2060-service-agent'
IMAGE_TAG: ${{ github.ref == 'refs/heads/main' && 'dev' || github.ref }}

jobs:
build:
Expand Down Expand Up @@ -70,24 +71,24 @@ jobs:
- name: Build Docker image
if: steps.semantic.outputs.new-release-published == 'true'
run: |
docker build -f Dockerfile -t $DH_USERNAME/$IMAGE_NAME:${GITHUB_REF##*/} .
docker build -f Dockerfile -t $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG .

- name: Add tags to Docker image and push to Docker Hub
if: steps.semantic.outputs.new-release-published == 'true'
run: |
docker tag $DH_USERNAME/$IMAGE_NAME:${GITHUB_REF##*/} $DH_USERNAME/$IMAGE_NAME:v${RELEASE_MAJOR}-${GITHUB_REF##*/}
docker tag $DH_USERNAME/$IMAGE_NAME:${GITHUB_REF##*/} $DH_USERNAME/$IMAGE_NAME:v${RELEASE_MAJOR}.${RELEASE_MINOR}-${GITHUB_REF##*/}
docker tag $DH_USERNAME/$IMAGE_NAME:${GITHUB_REF##*/} $DH_USERNAME/$IMAGE_NAME:v${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_PATCH:0:1}-${GITHUB_REF##*/}
docker tag $DH_USERNAME/$IMAGE_NAME:${GITHUB_REF##*/} $DH_USERNAME/$IMAGE_NAME:v$RELEASE_VERSION
docker push $DH_USERNAME/$IMAGE_NAME:${GITHUB_REF##*/}
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR-${GITHUB_REF##*/}
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR.$RELEASE_MINOR-${GITHUB_REF##*/}
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR.$RELEASE_MINOR.${RELEASE_PATCH:0:1}-${GITHUB_REF##*/}
docker tag $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG $DH_USERNAME/$IMAGE_NAME:v${RELEASE_MAJOR}-$IMAGE_TAG
docker tag $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG $DH_USERNAME/$IMAGE_NAME:v${RELEASE_MAJOR}.${RELEASE_MINOR}-$IMAGE_TAG
docker tag $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG $DH_USERNAME/$IMAGE_NAME:v${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_PATCH:0:1}-$IMAGE_TAG
docker tag $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG $DH_USERNAME/$IMAGE_NAME:v$RELEASE_VERSION
docker push $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR-$IMAGE_TAG
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR.$RELEASE_MINOR-$IMAGE_TAG
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR.$RELEASE_MINOR.${RELEASE_PATCH:0:1}-$IMAGE_TAG
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_VERSION


- name: Add tags to Docker image and push to Docker Hub (specific to main)
if: github.ref == 'refs/heads/main' && steps.semantic.outputs.new-release-published == 'true'
- name: Add tags to Docker image and push to Docker Hub (specific to releases)
if: github.ref == 'refs/heads/release' && steps.semantic.outputs.new-release-published == 'true'
run: |
docker tag $DH_USERNAME/$IMAGE_NAME:${GITHUB_REF##*/} $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR
docker tag $DH_USERNAME/$IMAGE_NAME:${GITHUB_REF##*/} $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR.$RELEASE_MINOR
Expand Down