Skip to content

Commit b47ac4a

Browse files
Merge pull request #2086 from sunu/feature/build-docker-image-helm-chart-on-push
Build and push docker images and helm charts on every push to develop
2 parents cd0ec4f + 1786477 commit b47ac4a

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Builds and pushes Docker Images and Helm charts to Github Registry
2+
3+
on:
4+
# Build and push Docker image and Helm charts on every push to develop branch
5+
# and on every tag push
6+
push:
7+
branches:
8+
- develop
9+
tags:
10+
- "**"
11+
12+
permissions:
13+
packages: write
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Login to GitHub Container Registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Install chart publishing dependencies (chartpress, helm)
34+
run: |
35+
pip install chartpress
36+
pip list
37+
38+
helm version
39+
40+
- name: Build and push Docker image. Update the image tag, chart version etc as needed
41+
run: |
42+
cd deploy/helm
43+
# hack to push the image to ghcr.io. We will update chartpress.yaml when we move to separate deploy repo
44+
python -c "import re; data=open('chartpress.yaml').read(); open('chartpress.yaml', 'w').write(re.sub(r'ifrcgoacr.azurecr.io/ifrcgo-', 'ghcr.io/IFRCGo/go-', data))"
45+
chartpress --push
46+
47+
- name: Get the version
48+
id: get_version
49+
run: echo ::set-output name=VERSION::$(cat deploy/helm/ifrcgo-helm/Chart.yaml | grep version | awk '{print $2}')
50+
51+
- name: Package Helm Chart
52+
run: |
53+
helm package deploy/helm/ifrcgo-helm -d .helm-charts
54+
55+
- name: Push Helm Chart
56+
run: |
57+
helm push .helm-charts/ifrcgo-helm-${{ steps.get_version.outputs.VERSION }}.tgz oci://ghcr.io/IFRCGo/go-api

0 commit comments

Comments
 (0)