From 72981028efe2aee30bceee95ed6c9523bdd36b10 Mon Sep 17 00:00:00 2001 From: Jin Igarashi Date: Fri, 17 Nov 2023 14:35:54 +0000 Subject: [PATCH] chore: add CI to bump geohub data pipeline version (#2314) --- .github/workflows/bump-pipeline.yml | 39 ++++++++++++++++++++++ backends/k8s/data-pipeline/bump-version.sh | 20 +++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .github/workflows/bump-pipeline.yml create mode 100755 backends/k8s/data-pipeline/bump-version.sh diff --git a/.github/workflows/bump-pipeline.yml b/.github/workflows/bump-pipeline.yml new file mode 100644 index 000000000..571382024 --- /dev/null +++ b/.github/workflows/bump-pipeline.yml @@ -0,0 +1,39 @@ +name: Bump geohub-data-pipeline version +on: + # This workflow will be triggered when the new release tag is created on geohub-data-pipeline repository.concurrency: + # https://github.com/UNDP-Data/geohub-data-pipeline/blob/main/.github/workflows/acr_docker_image.yml + repository_dispatch: + types: [bump-pipeline-version] + workflow_dispatch: + +jobs: + bump-version: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: bump data-pipeline version + run: ./backends/k8s/data-pipeline/bump-version.sh + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + branch: release/bump-geohub-data-pipeline + title: "[RELEASE] bump version of geohub-data-pipeline" + delete-branch: true + commit-message: "[RELEASE] bump version of geohub-data-pipeline" + body: | + ## Description + + This is going to bump the version of geohub-data-pipeline to apply the new pipeline docker image to kubernetes cluster + + --- + - Auto-generated by [create-pull-request][1] + + [1]: https://github.com/peter-evans/create-pull-request + labels: release + reviewers: | + iferencik + Thuhaa + JinIgarashi diff --git a/backends/k8s/data-pipeline/bump-version.sh b/backends/k8s/data-pipeline/bump-version.sh new file mode 100755 index 000000000..6ec160b9b --- /dev/null +++ b/backends/k8s/data-pipeline/bump-version.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +yaml_file=./yaml/ingest-environment.yaml +url=https://api.github.com/repos/undp-data/geohub-data-pipeline/releases/latest + +# extract the latest tag version +tag_name=$(curl -s $url | jq --raw-output '.tag_name') + +echo "Latest release version: $tag_name" + +imagename="undpgeohub.azurecr.io/geohub-data-pipeline" +pattern="${imagename}:[^ ]*" +sed -E "s|$pattern|$imagename:$tag_name|g" $yaml_file > "${yaml_file}_new" + +cat "${yaml_file}_new" + +# replace yaml file with new version +mv "${yaml_file}_new" $yaml_file + +echo "tag version was replace to $tag_name"