Skip to content

Release Helm Chart #1077

Release Helm Chart

Release Helm Chart #1077

Workflow file for this run

# Workflow which is used for creating and publishing a new helm chart artifact on push / merge to
# main branch
name: "Release Helm Chart"
on:
# We only run this workflow if both test workflows complete successfully
workflow_run:
workflows:
# TODO: We can't depend on two workflows using "AND" condition (aka both workflows need to
# pass), so we just depend on the longer one. When specifying multiple workflows it uses
# "OR" behavior.
- "End to End Tests"
branches:
- main
types:
- completed
# push:
# branches:
# - main
permissions:
contents: write # needed so we can publish page update
packages: write # needed so we can publish a package / artifact
jobs:
release:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# here we want to check out all the branches
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
with:
version: "latest"
# Needed so it can fetch latest version
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run chart-releaser
uses: helm/chart-releaser-action@be16258da8010256c6e82849661221415f031968 # v1.4.0
env:
CR_TOKEN: "${{ github.token }}"
with:
charts_dir: charts
- name: Write latest stable version to info.json file
run: |
# We write latest stable version info to JSON file which we can query for displaying
# badge in the readme
CHART_VERSION=$(cat charts/scalyr-agent/Chart.yaml | grep "version: " | sed "s/version: //g" | tr -d "\n")
cp README.md /tmp/README.md
git fetch origin
git checkout gh-pages
echo "Copying over README.md from main branch"
cp /tmp/README.md README.md
git add README.md
git commit -m "Update README.md file" || true
echo "File content before update"
cat info.json
echo '{"scalyrAgent": "v'${CHART_VERSION}'"}' > info.json
echo "File content after update"
cat info.json
git add info.json
git commit -m "Update info.json file" || true
git push origin gh-pages || true
- name: Notify Slack on Failure
# NOTE: github.ref is set to pr ref (and not branch name, e.g. refs/pull/28/merge) for pull
# requests and that's why we need this special conditional and check for github.head_ref in
# case of PRs
if: ${{ failure() && (github.ref == 'refs/heads/main' || github.head_ref == 'main') }}
uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f # v2.0.0
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#cloud-tech'