Skip to content

Commit 58db195

Browse files
Shreyas SrivathsaShreyas Srivathsa
authored andcommitted
Update workflow to include logic to update gitops repo
1 parent bbceaf6 commit 58db195

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

.github/workflows/build-and-push.yaml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ on:
99

1010
# update image tags based on update to each component here
1111
env:
12-
PRODUCER_IMAGE: producer:1.0.0
13-
PROCESSOR_IMAGE: processor:1.0.0
14-
GRPC_SERVER_IMAGE: grpc-server:1.0.0
15-
GRPC_CLIENT_IMAGE: grpc-client:1.0.0
12+
PRODUCER_IMAGE: producer:2.0.0
13+
PROCESSOR_IMAGE: processor:2.0.0
14+
GRPC_SERVER_IMAGE: grpc-server:2.0.0
15+
GRPC_CLIENT_IMAGE: grpc-client:2.0.0
16+
GITOPS_REPO: srivathsashreyas/metrics-collector-py-gitops
1617

1718
jobs:
1819

@@ -71,4 +72,27 @@ jobs:
7172
- name: Build the client image
7273
run: docker build -f deploy/client/Dockerfile -t docker.io/${{ secrets.DOCKERHUB_USERNAME }}/${{env.GRPC_CLIENT_IMAGE}} .
7374
- name: Push the client image
74-
run: docker push docker.io/${{ secrets.DOCKERHUB_USERNAME }}/${{env.GRPC_CLIENT_IMAGE}}
75+
run: docker push docker.io/${{ secrets.DOCKERHUB_USERNAME }}/${{env.GRPC_CLIENT_IMAGE}}
76+
77+
update-image-tags-in-gitops-repo:
78+
needs: [build-and-push-producer, build-and-push-processor, build-and-push-grpc-server, build-and-push-grpc-client]
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: Checkout gitops repo
82+
uses: actions/checkout@v4
83+
with:
84+
repository: ${{ env.GITOPS_REPO }}
85+
token: ${{ secrets.REPO_PAT }}
86+
- name: Update image tags in values.yaml based on env specification
87+
run: |
88+
sed -i -r 's/grpc-client:(.)+/grpc-client:${{env.GRPC_CLIENT_IMAGE}}/g' values.yaml
89+
sed -i -r 's/grpc-server:(.)+/grpc-server:${{env.GRPC_SERVER_IMAGE}}/g' values.yaml
90+
sed -i -r 's/processor:(.)+/processor:${{env.PROCESSOR_IMAGE}}/g' values.yaml
91+
sed -i -r 's/producer:(.)+/producer:${{env.PRODUCER_IMAGE}}/g' values.yaml
92+
- name: Commit and push changes
93+
run: |
94+
git config user.name "github-actions[bot]"
95+
git config user.email "github-actions[bot]@users.noreply.github.com"
96+
git add values.yaml
97+
git commit -m "Update image tags in values.yaml"
98+
git push

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The project is structured as follows:
3939
## Deployment Steps (Local with Colima)
4040

4141
1. Ensure you've built all relevant images. For example to build the producer image, run
42-
`podman build -f deploy/producer/Dockerfile -t producer .`. Ensure that the tags match those specified in the corresponding k8s manifest files
42+
`podman build -f deploy/producer/Dockerfile -t producer .`. Ensure that the tags match those specified in the corresponding k8s manifest files. Note: You may need to modify the JAVA_HOME path in the processor Dockerfile based on your system architecture (arm64 for apple silicon, amd64 for intel/amd)
4343
2. Save the images as a tar file. For example, to save the producer image, run
4444
`podman save -o producer.tar producer:latest`
4545
3. Start Colima with Kubernetes enabled (skip this step if you already have k3s running on your system) -> `colima start --kubernetes --runtime containerd --cpu 4 --memory 4`

0 commit comments

Comments
 (0)