Skip to content

Update RS Proxy Docker Image Tags (Main Branch) #53

Update RS Proxy Docker Image Tags (Main Branch)

Update RS Proxy Docker Image Tags (Main Branch) #53

Workflow file for this run

# This GitHub workflow will automatically update docker image tags of rs-proxy-depl in the datakaveri/iudx-deployment repository files, whenever a docker image is pushed to ghcr.io/datakaveri/rs-proxy-depl for the master/main branch (5.6.0-alpha)
name: Update RS Proxy Docker Image Tags (Main Branch)
on:
registry_package:
types: [published]
permissions:
packages: read
jobs:
update-master:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
repository: datakaveri/iudx-deployment
token: "${{ secrets.JENKINS_UPDATE }}"
fetch-depth: 0
- name: Update RS Proxy Docker Image Tags for Master/Main Branch
env:
GH_TOKEN: ${{ secrets.JENKINS_UPDATE }}
run: |
# Get the latest version of 5.6.0-alpha tags from the container registry using GitHub API
export newtag5_6_0=$(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/orgs/datakaveri/packages/container/rs-proxy-depl/versions | jq ' .[].metadata.container.tags[0]' | grep 5.6.0-alpha | head -n 1 | sed -e 's/^"//' -e 's/"$//')
# Get the current tag from the YAML files
export oldtag5_6_0=$(yq -r .services.rs-proxy.image Docker-Swarm-deployment/single-node/rs-proxy/rs-proxy-stack.yaml | cut -d : -f 2)
# Set Git user
git config --global user.name 'jenkins-datakaveri'
git config --global user.email "96175780+jenkins-datakaveri@users.noreply.github.com"
# Update the YAML files and create a new branch for the tag update
if [ "$newtag5_6_0" != "$oldtag5_6_0" ]; then
git checkout master
git checkout -b rs-proxy-5.6.0-alpha-updates/$newtag5_6_0
# Replace old tag with new tag in the YAML files
sed -i "s/$oldtag5_6_0/$newtag5_6_0/g" Docker-Swarm-deployment/single-node/rs-proxy/rs-proxy-stack.yaml
# Update the version in the Chart.yaml and values.yaml files
export oldappversion=$(yq -r .version K8s-deployment/Charts/rs-proxy/Chart.yaml)
export newappversion=$(yq -r .version K8s-deployment/Charts/rs-proxy/Chart.yaml | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}')
sed -i "s/$oldappversion/$newappversion/g" K8s-deployment/Charts/rs-proxy/Chart.yaml
sed -i "s/$oldtag5_6_0/$newtag5_6_0/g" K8s-deployment/Charts/rs-proxy/values.yaml
git add Docker-Swarm-deployment/single-node/rs-proxy/rs-proxy-stack.yaml K8s-deployment/Charts/rs-proxy/values.yaml K8s-deployment/Charts/rs-proxy/Chart.yaml
git commit --allow-empty -m "Updated RS Proxy Docker image tag to $newtag5_6_0"
git push --set-upstream origin rs-proxy-5.6.0-alpha-updates/$newtag5_6_0
# Create a new pull request
gh pr create -R datakaveri/iudx-deployment --base master --fill
fi