Skip to content

Commit

Permalink
ci: tag version only from release (#975)
Browse files Browse the repository at this point in the history
Co-authored-by: Levente Orban <levente.orban@dyrector.io>
  • Loading branch information
nandor-magyar and polaroi8d committed May 21, 2024
1 parent 271c946 commit d6c5301
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 23 deletions.
28 changes: 16 additions & 12 deletions .github/workflows/pipeline_set_output_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,37 @@ github_ref_name=$2
github_sha=$3
github_base_ref=${4:-""}

DOCKERIMAGETAG="$github_sha"
IMAGETAG="$github_sha"
EXTRATAG=""
# These values are wrong on purpose: if we see these default values in the wild,
# we will know something happened that shouldn't have
VERSION="v0.0.0"
MINORVERSION="v0.0.0"

if [ "$github_ref_type" = "branch" ]; then
case $github_ref_name in
"main") DOCKERIMAGETAG="stable"
"main") IMAGETAG="stable"
;;
"develop") DOCKERIMAGETAG="latest"
"develop") IMAGETAG="latest"
;;
esac

if [ $github_base_ref = "main" ]; then
DOCKERIMAGETAG="stable"
elif [ $github_base_ref != "" ]; then
DOCKERIMAGETAG="latest"
if [ "$github_base_ref" = "main" ]; then
IMAGETAG="stable"
elif [ "$github_base_ref" != "" ]; then
IMAGETAG="latest"
fi
fi

if [ "$github_ref_type" = "tag" ]; then
DOCKERIMAGETAG=$github_ref_name
elif [ "$github_ref_type" = "tag" ]; then
IMAGETAG="$github_ref_name"
EXTRATAG="stable"
VERSION=$github_ref_name
MINORVERSION=$(echo "$github_ref_name"| cut -d. -f1-2)
else
echo unexpected github_ref_type
exit 1
fi

echo "tag=$DOCKERIMAGETAG" >> "$GITHUB_OUTPUT"
echo "tag=$IMAGETAG" >> "$GITHUB_OUTPUT"
echo "extratag=$EXTRATAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "minorversion=$MINORVERSION" >> "$GITHUB_OUTPUT"
49 changes: 38 additions & 11 deletions .github/workflows/product_builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: product_builder
on:
push:
branches: [develop, main]
tags: ['*']
release:
types:
- "published"
pull_request:
types: [edited, opened, synchronize, reopened]
permissions:
Expand All @@ -24,7 +26,7 @@ env:
KRATOS_WORKING_DIRECTORY: web/kratos
GOLANG_WORKING_DIRECTORY: golang
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.sha }}
cancel-in-progress: true
jobs:
conventional_commits:
Expand Down Expand Up @@ -68,6 +70,7 @@ jobs:
cruxui: ${{ steps.filter.outputs.cruxui }}
kratos: ${{ steps.filter.outputs.kratos }}
tag: ${{ steps.settag.outputs.tag }}
extratag: ${{ steps.settag.outputs.extratag }}
version: ${{ steps.settag.outputs.version }}
minorversion: ${{ steps.settag.outputs.minorversion }}
release: ${{ steps.release.outputs.release }}
Expand Down Expand Up @@ -519,7 +522,7 @@ jobs:
# runs-on: self-hosted
container:
image: ghcr.io/dyrector-io/dyrectorio/playwright:latest
volumes: ['/var/run/docker.sock:/var/run/docker']
volumes: ["/var/run/docker.sock:/var/run/docker"]
needs:
- go_build
- crux_build
Expand Down Expand Up @@ -613,11 +616,11 @@ jobs:
# DEBUG: pw:api
HUB_PROXY_URL: ${{ secrets.HUB_PROXY_URL }}
HUB_PROXY_TOKEN: ${{ secrets.HUB_PROXY_TOKEN }}
E2E_BASE_URL: 'http://dyo-e2e_traefik:8000'
MAILSLURPER_URL: 'http://dyo-e2e_mailslurper:4437'
CRUX_UI_URL: 'http://dyo-e2e_traefik:8000'
KRATOS_URL: 'http://dyo-e2e_kratos:4433'
KRATOS_ADMIN_URL: 'http://dyo-e2e_kratos:4434'
E2E_BASE_URL: "http://dyo-e2e_traefik:8000"
MAILSLURPER_URL: "http://dyo-e2e_mailslurper:4437"
CRUX_UI_URL: "http://dyo-e2e_traefik:8000"
KRATOS_URL: "http://dyo-e2e_kratos:4433"
KRATOS_ADMIN_URL: "http://dyo-e2e_kratos:4434"
CI: true
run: |
npm ci --include=dev --arch=x64 --cache .npm --prefer-offline --no-fund
Expand Down Expand Up @@ -763,6 +766,15 @@ jobs:
crane cp ${GITHUB_REGISTRY}/${CRANE_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/crane:${{ needs.gather_changes.outputs.tag }}
crane cp ${GITHUB_REGISTRY}/${DAGENT_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/dagent:${{ needs.gather_changes.outputs.tag }}
crane cp ${GITHUB_REGISTRY}/${CLI_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/dyo:${{ needs.gather_changes.outputs.tag }}
- name: Docker tag extra
if: ${{ needs.gather_changes.outputs.extratag != '' }}
run: |
crane cp ${GITHUB_REGISTRY}/${CRANE_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/crane:${{ needs.gather_changes.outputs.extratag }}
crane cp ${GITHUB_REGISTRY}/${DAGENT_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/dagent:${{ needs.gather_changes.outputs.extratag }}
crane cp ${GITHUB_REGISTRY}/${CLI_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/dyo:${{ needs.gather_changes.outputs.extratag }}
crane cp ${GITHUB_REGISTRY}/${CRANE_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${GITHUB_REGISTRY}/${CRANE_IMAGE_NAME}:${{ needs.gather_changes.outputs.extratag }}
crane cp ${GITHUB_REGISTRY}/${DAGENT_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${GITHUB_REGISTRY}/${DAGENT_IMAGE_NAME}:${{ needs.gather_changes.outputs.extratag }}
crane cp ${GITHUB_REGISTRY}/${CLI_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${GITHUB_REGISTRY}/${CLI_IMAGE_NAME}:${{ needs.gather_changes.outputs.extratag }}
- name: Add minor version tag
if: github.ref_type == 'tag'
run: |
Expand Down Expand Up @@ -823,12 +835,17 @@ jobs:
- name: Docker tag
run: |
docker tag ${GITHUB_REGISTRY}/${CRUX_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/crux:${{ needs.gather_changes.outputs.tag }}
- name: Docker tag extra
if: ${{ needs.gather_changes.outputs.extratag != '' }}
run: |
docker tag ${GITHUB_REGISTRY}/${CRUX_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${GITHUB_REGISTRY}/${CRUX_IMAGE_NAME}:${{ needs.gather_changes.outputs.extratag }}
docker tag ${GITHUB_REGISTRY}/${CRUX_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/crux:${{ needs.gather_changes.outputs.extratag }}
- name: Add minor version tag
if: github.ref_type == 'tag'
run: |
docker tag ${GITHUB_REGISTRY}/${CRUX_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/crux:${{ needs.gather_changes.outputs.minorversion }}
docker tag ${GITHUB_REGISTRY}/${CRUX_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${GITHUB_REGISTRY}/${CRUX_IMAGE_NAME}:${{ needs.gather_changes.outputs.minorversion }}
- name: Docker tag
- name: Docker push all tags
run: |
docker push -a ${GITHUB_REGISTRY}/${CRUX_IMAGE_NAME}
docker push -a ${DOCKERHUB_REGISTRY}/crux
Expand Down Expand Up @@ -881,12 +898,17 @@ jobs:
- name: Docker tag
run: |
docker tag ${GITHUB_REGISTRY}/${CRUX_UI_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/crux-ui:${{ needs.gather_changes.outputs.tag }}
- name: Docker tag extra
if: ${{ needs.gather_changes.outputs.extratag != '' }}
run: |
docker tag ${GITHUB_REGISTRY}/${CRUX_UI_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${GITHUB_REGISTRY}/${CRUX_UI_IMAGE_NAME}:${{ needs.gather_changes.outputs.extratag }}
docker tag ${GITHUB_REGISTRY}/${CRUX_UI_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/crux-ui:${{ needs.gather_changes.outputs.extratag }}
- name: Add minor version tag
if: github.ref_type == 'tag'
run: |
docker tag ${GITHUB_REGISTRY}/${CRUX_UI_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/crux-ui:${{ needs.gather_changes.outputs.minorversion }}
docker tag ${GITHUB_REGISTRY}/${CRUX_UI_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${GITHUB_REGISTRY}/${CRUX_UI_IMAGE_NAME}:${{ needs.gather_changes.outputs.minorversion }}
- name: Docker push
- name: Docker push all tags
run: |
docker push -a ${GITHUB_REGISTRY}/${CRUX_UI_IMAGE_NAME}
docker push -a ${DOCKERHUB_REGISTRY}/crux-ui
Expand Down Expand Up @@ -939,12 +961,17 @@ jobs:
- name: Docker tag
run: |
docker tag ${GITHUB_REGISTRY}/${KRATOS_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/kratos:${{ needs.gather_changes.outputs.tag }}
- name: Docker tag extra
if: ${{ needs.gather_changes.outputs.extratag != '' }}
run: |
docker tag ${GITHUB_REGISTRY}/${KRATOS_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${GITHUB_REGISTRY}/${KRATOS_IMAGE_NAME}:${{ needs.gather_changes.outputs.extratag }}
docker tag ${GITHUB_REGISTRY}/${KRATOS_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/kratos:${{ needs.gather_changes.outputs.extratag }}
- name: Add minor version tag
if: github.ref_type == 'tag'
run: |
docker tag ${GITHUB_REGISTRY}/${KRATOS_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${DOCKERHUB_REGISTRY}/kratos:${{ needs.gather_changes.outputs.minorversion }}
docker tag ${GITHUB_REGISTRY}/${KRATOS_IMAGE_NAME}:${{ needs.gather_changes.outputs.tag }} ${GITHUB_REGISTRY}/${KRATOS_IMAGE_NAME}:${{ needs.gather_changes.outputs.minorversion }}
- name: Docker push
- name: Docker push all tags
run: |
docker push -a ${GITHUB_REGISTRY}/${KRATOS_IMAGE_NAME}
docker push -a ${DOCKERHUB_REGISTRY}/kratos
Expand Down

0 comments on commit d6c5301

Please sign in to comment.