Skip to content
61 changes: 59 additions & 2 deletions smoke-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ inputs:
description: 'The directory containing multiple yamls for a Replicated release.'
required: true
default: 'manifests'
version:
description: 'Provides version to use for the Replicated Release'
required: false
kubernetes-distribution:
description: 'Kubernetes distribution of the cluster to provision.'
required: true
Expand All @@ -39,12 +42,66 @@ inputs:
runs:
using: "composite"
steps:
- name: Extract Chart YAML
id: extract-chart-yaml
if: inputs.installation-method == 'helm' && inputs.version == ''
shell: bash
run: |
tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this will break if the yaml-dir doesn't contain a helm chart?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, all the manipulation of the chart will break, I should make those conditional

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made a few more things conditional

chart_yaml=$(tar -xzvf ${tarball} $(tar -tzf ${tarball} --exclude "*/charts/*" | grep Chart.yaml))
echo "CHART_YAML=${chart_yaml}" >> $GITHUB_ENV
env:
YAML_DIR: ${{ inputs.yaml-dir }}
CHART_NAME: ${{ inputs.helm-chart-name }}
- name: Get Chart Version
id: get-chart-version
if: inputs.installation-method == 'helm' && inputs.version == ''
uses: mikefarah/yq@master
with:
cmd: yq '.version' ${CHART_YAML}
- name: Define App Version
shell: bash
if: inputs.installation-method == 'helm' && inputs.version == ''
run: echo "APP_VERSION=${CHART_VERSION}+${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV
env:
CHART_VERSION: ${{ steps.get-chart-version.outputs.result }}
# there no good default here, going back to what Josh had since it's specific to the channel and the channel goes away
- name: Define App Version
shell: bash
run: echo "APP_VERSION=0.0.1-${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV
if: inputs.installation-method == 'kots' && inputs.version == ''
run: echo "APP_VERSION=0.1.0+${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV
env:
CHART_VERSION: ${{ steps.get-chart-version.outputs.result }}
- name: Use Explicit Version
shell: bash
if: inputs.version != ''
run: echo "APP_VERSION=${VERSION}" >> $GITHUB_ENV
env:
VERSION: ${{ inputs.version }}
- name: Define Channel Name
shell: bash
run: echo "CHANNEL_NAME=${{ github.ref_name }}-${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}-${{ inputs.kubernetes-distribution }}-${{ inputs.kubernetes-version }}" >> $GITHUB_ENV
- name: Update Chart YAML
id: update-chart-yaml
if: inputs.version == ''
uses: mikefarah/yq@master
with:
cmd: yq -i '.version = "${{ env.APP_VERSION }}"' ${CHART_YAML}
- name: Update Chart Version
id: update-chart-version
shell: bash
if: inputs.installation-method == 'helm' && inputs.version == ''
run: |
# update the chart version to match the Replicated app version
tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz")
mkdir -p /tmp/repack
tar -xf ${tarball} -C /tmp/repack
helm package --version "${{ env.APP_VERSION }}" /tmp/repack/${CHART_NAME}*
mv ${{ inputs.helm-chart-name }}-${{env.APP_VERSION }}.tgz $(dirname ${tarball})
rm ${tarball}
env:
YAML_DIR: ${{ inputs.yaml-dir }}
CHART_NAME: ${{ inputs.helm-chart-name }}
- name: 'Create Release'
id: 'create-release'
uses: replicatedhq/compatibility-actions/create-release@v0
Expand Down Expand Up @@ -124,4 +181,4 @@ runs:
with:
app-slug: ${{ inputs.app-slug }}
api-token: ${{ inputs.api-token }}
channel-slug: ${{ steps.create-release.outputs.channel-slug }}
channel-slug: ${{ steps.create-release.outputs.channel-slug }}