Skip to content

Commit 4bbec4d

Browse files
authored
refactor(main): auto package for tag (#124)
Signed-off-by: cuisongliu <[email protected]>
1 parent c93e0bb commit 4bbec4d

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

.github/workflows/pages.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
name: Deploy Jekyll with GitHub Pages dependencies preinstalled
33

44
on:
5-
# Runs on pushes targeting the default branch
6-
push:
7-
branches: ["main"]
8-
95
# Allows you to run this workflow manually from the Actions tab
106
workflow_dispatch:
117
repository_dispatch:
@@ -42,7 +38,11 @@ jobs:
4238
destination: ./_site
4339
- name: Helm package
4440
run: |
45-
bash helm.sh
41+
if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then
42+
bash helm.sh ${{ github.event.client_payload.ref }}
43+
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
44+
bash helm.sh
45+
fi
4646
sudo cp index.yaml _site/
4747
- name: Upload artifact
4848
uses: actions/upload-pages-artifact@v1

helm.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
# 仓库名称
44
repository="labring/endpoints-operator"
55

6-
# 获取最新release的版本号
7-
latest_release=$(curl -s "https://api.github.com/repos/$repository/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
6+
# 版本号参数
7+
version=$1
8+
9+
if [[ -z "$version" ]]; then
10+
# 获取最新release的版本号
11+
version=$(curl -s "https://api.github.com/repos/$repository/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
12+
fi
13+
814
# 构建下载链接
9-
download_url="https://github.com/$repository/releases/download/$latest_release/endpoints-operator-${latest_release#v}.tgz"
15+
download_url="https://github.com/$repository/releases/download/$version/endpoints-operator-${version#v}.tgz"
1016

11-
# 下载最新release
17+
# 下载指定版本的release
1218
wget $download_url
1319

14-
helm repo index . --url https://github.com/$repository/releases/download/$latest_release
20+
helm repo index . --url https://github.com/$repository/releases/download/$version

0 commit comments

Comments
 (0)