Skip to content

Merge pull request #2305 from IFRCGo/feature/fix-log-dump-and-tranlsa… #61

Merge pull request #2305 from IFRCGo/feature/fix-log-dump-and-tranlsa…

Merge pull request #2305 from IFRCGo/feature/fix-log-dump-and-tranlsa… #61

name: Builds and pushes Docker Images and Helm charts to Github Registry
on:
# Build and push Docker image and Helm charts on every push to develop branch
# and on every tag push
push:
branches:
- develop
- master
- project/*
tags:
- "**"
permissions:
packages: write
jobs:
ci:
name: CI
uses: ./.github/workflows/ci.yml
build:
name: Publish Helm
needs: ci
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install chart publishing dependencies (chartpress, helm)
run: |
python3 -m venv venv
source venv/bin/activate
pip install chartpress
pip list
helm version
- name: Build and push Docker image. Update the image tag, chart version etc as needed
run: |
source venv/bin/activate
cd deploy/helm
# hack to push the image to ghcr.io. We will update chartpress.yaml when we move to separate deploy repo
if [[ "$GITHUB_REF_NAME" == "project/"* ]]; then
# NOTE: Using seperate package registry for alpha
python -c "import re; data=open('chartpress.yaml').read(); open('chartpress.yaml', 'w').write(re.sub(r'ifrcgoacr.azurecr.io/ifrcgo-', 'ghcr.io/ifrcgo/alpha-go-', data))"
else
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))"
fi
chartpress --push
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::$(cat deploy/helm/ifrcgo-helm/Chart.yaml | grep version | awk '{print $2}')
- name: Package Helm Chart
run: |
if [[ "$GITHUB_REF_NAME" == "project/"* ]]; then
# NOTE: Using seperate package registry for alpha
sed -i 's/^name: \(.*\)/name: alpha-\1/' deploy/helm/ifrcgo-helm/Chart.yaml
fi
helm package deploy/helm/ifrcgo-helm -d .helm-charts
- name: Push Helm Chart
run: |
if [[ "$GITHUB_REF_NAME" == "project/"* ]]; then
helm push ".helm-charts/alpha-ifrcgo-helm-${{ steps.get_version.outputs.VERSION }}.tgz" oci://ghcr.io/ifrcgo/go-api
else
helm push ".helm-charts/ifrcgo-helm-${{ steps.get_version.outputs.VERSION }}.tgz" oci://ghcr.io/ifrcgo/go-api
fi