Forward merge release/kubernetes-agent/v1 #1082
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Kubernetes Agent chart | |
on: | |
push: | |
branches: | |
- main | |
- release/kubernetes-agent/v* | |
pull_request: | |
jobs: | |
paths_filter: | |
runs-on: ubuntu-latest | |
outputs: | |
result: ${{ steps.filter.outputs.kubernetes-agent }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
kubernetes-agent: | |
- charts/kubernetes-agent/** | |
- .github/workflows/kubernetes-agent-publish-chart.yaml | |
test: | |
needs: paths_filter | |
if: needs.paths_filter.outputs.result == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.13.2 | |
- name: Run Helm unit tests | |
run: | | |
helm plugin install https://github.com/helm-unittest/helm-unittest.git | |
helm unittest charts/kubernetes-agent | |
check-readme: | |
needs: paths_filter | |
if: needs.paths_filter.outputs.result == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v4 | |
- name: Generate docs | |
working-directory: charts/kubernetes-agent | |
run: "npm run generate-agent-docs" | |
- name: Check readme is unchanged | |
run: | | |
echo "Ensuring readme is up-to-date" | |
echo "If this test fails, run 'npm run generate-agent-docs' locally and commit the changes" | |
git diff --ignore-cr-at-eol -w --exit-code | |
version_and_package: | |
needs: test | |
runs-on: ubuntu-latest | |
outputs: | |
CHART_VERSION: ${{ steps.version.outputs.CHART_VERSION }} | |
PACKAGE_NAME: ${{ steps.version.outputs.PACKAGE_NAME }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: 'v3.13.2' | |
- name: Parse Chart config | |
uses: pietrobolcato/[email protected] | |
id: read_chart_yaml | |
with: | |
config: ${{ github.workspace }}/charts/kubernetes-agent/Chart.yaml | |
- name: Get branch names | |
id: branch_names | |
uses: OctopusDeploy/util-actions/[email protected] | |
- name: Generate chart version | |
id: version | |
shell: bash | |
run: | | |
chart_version="${{ steps.read_chart_yaml.outputs.version }}" | |
pre_release="" | |
if [[ "${{steps.branch_names.outputs.branch_name}}" != "main" ]] | |
then | |
# underscores in branches make for illegal version-string, replace with "-" | |
cleansed_branch=`echo ${{steps.branch_names.outputs.branch_name}} | sed s/_/-/g` | |
pre_release="-${cleansed_branch}-$(date +'%Y%m%d%H%M%S')" | |
fi | |
full_version="$chart_version$pre_release" | |
echo "CHART_VERSION=$full_version" >> $GITHUB_OUTPUT | |
echo "PACKAGE_NAME=kubernetes-agent-$full_version.tgz" >> $GITHUB_OUTPUT | |
- name: Package Chart | |
run: helm package './charts/kubernetes-agent' --version '${{ steps.version.outputs.CHART_VERSION }}' | |
- uses: actions/upload-artifact@v4 | |
name: Upload packaged chart | |
with: | |
name: '${{ steps.version.outputs.PACKAGE_NAME }}' | |
path: '${{ github.workspace }}/kubernetes-agent-${{ steps.version.outputs.CHART_VERSION }}.tgz' | |
publish_to_octopus: | |
runs-on: ubuntu-latest | |
# We publish to Artifactory if this is not a main commit, or if it is, that it's a versioning commit | |
if: ${{ github.ref != 'refs/heads/main' || (github.ref == 'refs/heads/main' && startsWith(github.event.commits[0].message, 'Version Charts')) }} | |
needs: version_and_package | |
permissions: | |
# You might need to add other permissions here like `contents: read` depending on what else your job needs to do | |
id-token: write # This is required to obtain an ID token from GitHub Actions for the job | |
steps: | |
- name: Download packaged chart | |
uses: actions/download-artifact@v4 | |
with: | |
name: '${{ needs.version_and_package.outputs.PACKAGE_NAME }}' | |
- name: Login to Octopus | |
uses: OctopusDeploy/login@v1 | |
with: | |
server: ${{ vars.OCTOPUS_SERVER }} | |
service_account_id: ${{ secrets.OCTOPUS_SERVICE_ACCOUNT }} | |
- name: Push helm chart to Octopus Deploy 🐙 | |
uses: OctopusDeploy/push-package-action@v3 | |
with: | |
space: 'Modern Deployments' | |
packages: ${{ needs.version_and_package.outputs.PACKAGE_NAME }} | |
overwrite_mode: IgnoreIfExists | |
- name: Create a release in Octopus Deploy 🐙 | |
uses: OctopusDeploy/create-release-action@v3 | |
with: | |
space: 'Modern Deployments' | |
project: 'Octopus Kubernetes Agent' | |
release_number: ${{ needs.version_and_package.outputs.CHART_VERSION }} | |
package_version: ${{ needs.version_and_package.outputs.CHART_VERSION }} | |
ignore_existing: true |