-
Notifications
You must be signed in to change notification settings - Fork 4
89 lines (71 loc) · 2.95 KB
/
octopus-publish-chart.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Publish Octopus Deploy Chart
on:
push:
branches:
- main
- release/octopus-deploy/v*
workflow_dispatch:
jobs:
paths_filter:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.filter.outputs.octopus-deploy }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
octopus-deploy:
- charts/octopus-deploy/**
- .github/workflows/octopus-publish-chart.yml
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.15.3'
- name: Run Helm unit tests
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest.git
helm unittest charts/octopus-deploy
- name: Login to GitHub container registry
run: echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io -u ${{github.actor}} --password-stdin
- name: Parse Chart config
uses: pietrobolcato/[email protected]
id: read_chart_yaml
with:
config: ${{ github.workspace }}/charts/octopus-deploy/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=octopusdeploy-helm-$full_version.tgz" >> $GITHUB_OUTPUT
- name: Package Chart
run: helm package --version '${{ steps.version.outputs.CHART_VERSION }}' 'charts/octopus-deploy'
- uses: actions/upload-artifact@v4
name: Upload packaged chart
with:
name: '${{ steps.version.outputs.PACKAGE_NAME }}'
path: '${{ github.workspace }}/octopusdeploy-helm-${{ steps.version.outputs.CHART_VERSION }}.tgz'
# Only push the chart for real if it's a branch build OR it's the versioning PR
- name: Push Chart
if: ${{ github.ref != 'refs/heads/main' || (github.ref == 'refs/heads/main' && startsWith(github.event.commits[0].message, 'Version Charts')) }}
run: helm push "octopusdeploy-helm-${{ steps.version.outputs.CHART_VERSION }}.tgz" oci://ghcr.io/octopusdeploy