Skip to content

Update Helm Chart Version and Create Pull Request #66496

Update Helm Chart Version and Create Pull Request

Update Helm Chart Version and Create Pull Request #66496

Workflow file for this run

name: Update Helm Chart Version and Create Pull Request
on:
schedule:
- cron: '*/5 * * * *' # Runs every 5 minutes
workflow_dispatch: # Allows manual trigger
permissions:
id-token: write
contents: write
pull-requests: write
env:
REGISTRY: ${{ secrets.ALTINN_REGISTRY }}
APP_NAME: altinn-receipt
jobs:
update-helm-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: 'Azure login'
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Get latest Helm chart version from ACR
id: get-latest-version
run: |
latest_version=$(az acr repository show-tags --name ${{ env.REGISTRY }} --repository charts/${{ env.APP_NAME }} --output tsv --orderby time_desc --top 1)
# Replace `_` with `+`, this is due to the oci repo not supporting `+` in tags
echo "latest_version=${latest_version//_/+}" >> $GITHUB_ENV
- name: Extract current version from YAML
id: extract-current-version
run: |
current_version=$(yq eval '.spec.chart.spec.version' .deploy/app.yaml)
echo "current_version=$current_version" >> $GITHUB_ENV
- name: Compare versions
id: compare-versions
run: |
if [ "${{ env.latest_version }}" != "${{ env.current_version }}" ]; then
echo "::set-output name=should_update::true"
else
echo "::set-output name=should_update::false"
fi
- name: Update YAML file
if: steps.compare-versions.outputs.should_update == 'true'
run: |
yq eval '.spec.chart.spec.version = "${{ env.latest_version }}"' -i .deploy/app.yaml
- name: Create Pull Request
if: steps.compare-versions.outputs.should_update == 'true'
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
token: ${{ secrets.GITHUB_TOKEN }}
delete-branch: true
commit-message: 'Update Helm chart to version ${{ env.latest_version }}'
title: 'Update Helm chart to version ${{ env.latest_version }}'
body: |
- The Helm chart has been updated to version ${{ env.latest_version }}.
Auto-generated by GitHub Actions.
branch: update-helm-chart-${{ env.latest_version }}
- name: Clean up
if: steps.compare-versions.outputs.should_update == 'true'
run: git checkout main
- name: Send Trace to Azure Monitor
uses: altinn/altinn-platform/actions/send-ci-cd-trace@cc4b775eb4d7015674bfcaac762e40f270afab87 # v1.0.1
with:
connection_string: ${{ secrets.APP_INSIGHTS_CONNECTION_STRING }}
app: '${{ env.APP_NAME }}'
team: 'core'
repo_token: ${{ secrets.GITHUB_TOKEN }}