-
Notifications
You must be signed in to change notification settings - Fork 570
133 lines (121 loc) · 4.21 KB
/
publish-helm.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Publish Helm Charts
# Do not change this
concurrency: publish-helm
env:
HELM_REPO_URL: https://helm.skypilot.co
permissions:
contents: write
pages: write
on:
workflow_call:
inputs:
version:
description: "Version to set in Chart.yaml"
required: false
type: string
commit_message:
description: "Git commit message"
required: false
type: string
package_name:
description: "Package name to use as chart name and docker image name"
required: false
type: string
default: "skypilot-nightly"
secrets:
DOCKER_USERNAME:
required: true
HELM_DEPLOY_KEY:
required: true
workflow_dispatch:
inputs:
version:
description: "Version to set in Chart.yaml"
required: false
type: string
commit_message:
description: "Git commit message"
required: false
type: string
default: "Updated from ref: $GITHUB_SHA"
package_name:
description: "Package name to use as chart name and docker image name"
required: false
type: string
default: "skypilot-nightly"
secrets:
DOCKER_USERNAME:
required: true
HELM_DEPLOY_KEY:
required: true
jobs:
publish-helm:
# Skip if triggered by release workflow
if: ${{ !contains(github.event.head_commit.message, 'Release version') }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: 'src'
fetch-depth: 0
- name: Configure SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.HELM_DEPLOY_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
cat >> ~/.ssh/config << EOF
Host github.com
IdentityFile ~/.ssh/deploy_key
StrictHostKeyChecking no
EOF
- name: Checkout Helm Repository
uses: actions/checkout@v3
with:
path: 'dest'
repository: 'skypilot-org/skypilot-helm'
ssh-key: ${{ secrets.HELM_DEPLOY_KEY }}
fetch-depth: 0
- name: Install Helm
uses: azure/setup-helm@v4
- name: Update Chart Version and Name
if: inputs.version != ''
run: |
version="${{ inputs.version }}"
# Convert PEP440 version to SemVer if needed for Helm versioning
# Handle cases like 1.0.0.dev20250218 -> 1.0.0-dev.20250218
semversion=$(echo "$version" | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+)\.dev([0-9]+)/\1-dev.\2/')
# Update the version and name in the Chart.yaml file
sed -i "s/^version:.*$/version: ${semversion}/" src/charts/skypilot/Chart.yaml
sed -i "s/^appVersion:.*$/appVersion: ${version}/" src/charts/skypilot/Chart.yaml
sed -i "s/^name:.*$/name: ${{ inputs.package_name }}/" src/charts/skypilot/Chart.yaml
- name: Update docker image in charts
if: inputs.version != ''
run: |
# Update the image in values.yaml
sed -i "s|image: .*$|image: ${{ secrets.DOCKER_USERNAME }}/${{ inputs.package_name }}:${{ inputs.version }}|" src/charts/skypilot/values.yaml
# Print the new values.yaml for debugging
cat src/charts/skypilot/values.yaml
- name: Package Helm Charts
shell: bash
run: |
find src/charts/ -type f -name 'Chart.yaml' | sed -r 's|/[^/]+$||' | sort | uniq | xargs -L 1 helm dep up
for d in src/charts/*/ ; do
echo "$d"
helm package "$d" -u -d dest
done
- name: Push New Files
shell: bash
working-directory: dest
run: |
helm repo index . --url ${{ env.HELM_REPO_URL }}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Add both untracked files and .tgz files explicitly
git add $(git ls-files -o --exclude-standard)
git add *.tgz
git add index.yaml
# Show what's being committed for debugging
git status
git commit -m "${{ inputs.commit_message || format('Updated from ref: {0}', github.sha) }}"
git push origin main