Skip to content

0.29.1

0.29.1 #247

Workflow file for this run

---
name: publish helm chart
on: # yamllint disable-line rule:truthy
workflow_dispatch:
inputs:
tag:
description: Release Tag
required: true
default: 0.0.0
type: string
release:
types:
- published
jobs:
publish:
name: publish
if: github.repository == 'determined-ai/determined'
runs-on: ubuntu-latest
permissions:
contents: write
env:
NEW_CHART_DIR: /tmp/newchart
GH_TOKEN: ${{ secrets.DETERMINED_TOKEN }}
steps:
# figure out release ID based on how we were run
- if: github.event_name == 'release'
run: |
# does github.event have the id in it already? Hmm...
#API=repos/{{ github.repository }}/releases/latest
#gh api $API -q '"rel_id=" + (.id|tostring)' >> $GITHUB_ENV
printf 'rel_id=${{ github.event.release.id }}\n' >> $GITHUB_ENV
- if: github.event_name == 'workflow_dispatch'
run: |
API=repos/${{ github.repository }}/releases/tags/${{ inputs.tag }}
gh api $API -q '"rel_id=" + (.id|tostring)' >> $GITHUB_ENV
# get the artifact for the chart and the branch for the chart repo
- name: check out chart repo branch
uses: actions/checkout@v4
with:
ref: helm-chart-repository
token: ${{ secrets.DETERMINED_TOKEN }}
- name: get chart artifact
run: |
NEW_CHART_DIR=$( mktemp -d )
pushd "$NEW_CHART_DIR"
ASSET_URL=$( \
gh api "repos/${{ github.repository }}/releases/${rel_id}/assets" \
-q '.[] | select(.name|test("determined-helm-chart.*")) | .url' \
)
#CHART_NAME=$( gh api $ASSET_URL -q '.name|sub("-helm-chart";"")' )
CHART_NAME=$( gh api $ASSET_URL -q .name )
gh api -H "Accept: application/octet-stream" "$ASSET_URL" \
> "$CHART_NAME"
popd
{
printf 'NEW_CHART_DIR=%s\n' "$NEW_CHART_DIR"
printf 'CHART_NAME=%s\n' "$CHART_NAME"
printf 'CHART_URL=%s\n' \
"$( gh api "$ASSET_URL" -q '.browser_download_url')"
} >> $GITHUB_ENV
# publish to GH Pages repository
# TODO: consider also publishing to artifact hub
- name: update index
run: |
helm repo index "$NEW_CHART_DIR" --merge index.yaml --url=replaceme
# diff returns 1 on difference, 2 on error, or 0 on no difference.
# We want difference.
if diff {"$NEW_CHART_DIR",.}/index.yaml
then
echo "No difference; chart probably already present"
exit -1
else
(( $? == 1 )) || exit $?
fi
sed "s|replaceme.*|${CHART_URL}|" \
< "$NEW_CHART_DIR"/index.yaml \
> index.yaml
- name: replace chart file with redirect
shell: python
run: |
from os import environ
from os.path import basename
from string import Template
chart_basename = basename( environ.get( 'CHART_NAME' ) )
environ['CHART_PERMALINK'] = '/' + chart_basename
with open('redirect_template.yaml', 'r') as src:
t = Template(src.read())
with open(chart_basename, 'w') as dst:
dst.write( t.safe_substitute(environ) )
with open( environ.get('GITHUB_ENV'), 'w+' ) as envfile:
envfile.write( f'CHART_REDIR_FILE={chart_basename}' )
- name: commit back
run: |
# commit as github-actions[bot] the magic email address is necessary
# to get the right icon to show up by the user on github. :)
git config user.name github-actions
git config user.email \
41898282+github-actions[bot]@users.noreply.github.com
git add "$CHART_REDIR_FILE"
# extract version from Chart.yaml
v=$( tar xOzf $NEW_CHART_DIR/$CHART_NAME --wildcards '*/Chart.yaml' \
| sed -n 's/^version: *//ip' )
msg="Add chart '$v' due to ${{ github.event_name }}"
git commit index.yaml $CHART_REDIR_FILE -m "$msg"
git push