1

I have a mono repo with NodeJS app (or better said, components of an app).

There are 3 apps in the repo, each has its own directory and Dockerfile:

  • /core
  • /worker
  • /frontend

There’s also /deployments directory which contains all Kustomize manifests that I'll be applying via ArgoCD.

The problem I’m facing is with this Github Actions workflow, in particular, the step at the end where I replace image tags in Kubernetes manifests in Kustomize dir and push changed files to another branch/repo.

      - name: Setting Image Tags/Annotations
        run: |
          for yaml in `find deployment/kustomize/base -type f -name "core-*.yaml" -print `; do sed -i "s/IMAGE_TAG/"$COMMIT_SHA"/g" $yaml; done
          for yaml in `find deployment/kustomize/base -type f -name "core-*.yaml" -print`; do sed -i "s/DEPLOY_TIMESTAMP/"$TIMESTAMP"/g" $yaml; done

      - name: Committing to Staging Branch
        run: |
          export COMMIT_MESSAGE=$(git log --format=%B -n 1 | sed '2d')
          git config --global user.name "CI"
          git config --global user.email "ci@github.com"
          git checkout -b staging
          git add .
          git commit -m "$COMMIT_MESSAGE"
          git push -u -f origin dummy

When I replace image tags in the way shown above, in any of those Kustomize files and commit them to the release branch it’s all good BUT if I do it again in future builds, all manifest that I pushed before get overwritten by other empty, non replaced manifests.

I’m not sure how to avoid this and preserve past changes in all manifests. Do you have any suggestions or advice?

I’m sure there’s a simple enough solution and that I’m likely overthinking this.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.