-
Notifications
You must be signed in to change notification settings - Fork 5
130 lines (125 loc) · 4.79 KB
/
check_zwave-js-ui.yaml
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
name: Check Latest ZWAVE-JS-UI
on:
schedule:
- cron: '20 5 * * *'
push:
paths:
- '.github/workflows/check_zwave-js-ui.yaml'
env:
imagePath: 'zwavejs/zwave-js-ui'
containerRepo: 'zwavejs/zwave-js-ui'
registryIndex: 'https://index.docker.io'
registryAuth: 'https://auth.docker.io'
chartPath: 'charts/zwave-js-ui'
versionKey: '.appVersion'
releaseType: 'patch'
jobs:
version-check:
runs-on: ubuntu-latest
name: Check and release new version
outputs:
discoveredversion: ${{ steps.check-changes.outputs.newversion }}
steps:
- name: checkout project
uses: actions/checkout@v3
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: prepate yq
run: |
curl https://github.com/mikefarah/yq/releases/download/`curl --silent "https://api.github.com/repos/mikefarah/yq/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")'`/yq_linux_amd64 -L -o yq
chmod 755 yq
- name: Find Latest stable version
id: check-changes
run: |
# Get Token from github registry
#NOOP=`curl ${registryAuth}/token\?service=registry.docker.io\&scope\="repository:${containerRepo}:pull" | jq -r '.token'`
# cut version and use it as Last
LAST=$(./yq eval "${versionKey}" ${chartPath}/Chart.yaml)
# register latest found
#FOUNDVER=$( curl -H "Authorization: Bearer $NOOP" ${registryIndex}/v2/${containerRepo}/tags/list\?last\="$LAST" |\
# jq -r '.tags[] | select(test("^[0-9]+[.][0-9]+[.][0-9]+$"))' |tail -1)
FOUNDVER=$(curl https://hub.docker.com/v2/repositories/zwavejs/zwave-js-ui/tags/\?page_size\=20\&page\=1\&ordering\=last_updated |\
jq -r '.results[].name | select(test("^[0-9]+[.][0-9]+[.][0-9]+$")) ' | head -1)
if [ $FOUNDVER != $LAST ]; then
echo "newversion=$FOUNDVER" >> $GITHUB_OUTPUT
echo "Found new version, will patch"
fi
echo "Current version is ${LAST} and found '${FOUNDVER}'"
patch-helm:
runs-on: ubuntu-latest
name: Patch Helm Chart
env:
NEWVERSION: ${{ needs.version-check.outputs.discoveredversion }}
needs: version-check
if: needs.version-check.outputs.discoveredversion != ''
steps:
- name: checkout project
uses: actions/checkout@v3
#with:
# token: ${{ secrets.READ_TOKEN }}
- name: prepare yq
run: |
curl https://github.com/mikefarah/yq/releases/download/`curl --silent "https://api.github.com/repos/mikefarah/yq/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")'`/yq_linux_amd64 -L -o yq
chmod 755 yq
- name: install helm plugins
run: |
helm plugin install https://github.com/sstarcher/helm-release
- name: compare found version to current
run: |
./yq -i "${versionKey} = \"${NEWVERSION}\"" ${chartPath}/Chart.yaml
- name: Run helm-docs
run: |
GOBIN=$PWD GO111MODULE=on go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
./helm-docs --sort-values-order file -c ${chartPath}
rm helm-docs
- name: bump chart version
id: bump-chart
run: |
helm release --bump=${releaseType} --source helm -s $chartPath
#- name: Run helm-docs
# run: |
# GOBIN=$PWD GO111MODULE=on go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
# ./helm-docs --sort-values-order file -c ${chartPath}
# rm helm-docs
- name: Commit latest release version
run: |
git config --global user.name 'Workflow-V'
git config --global user.email 'actions@aretakis.eu'
git add -A
git pull
git commit -am "New version for $chartPath with version $NEWVERSION"
git push
release:
runs-on: ubuntu-latest
if: needs.version-check.outputs.discoveredversion != ''
needs: patch-helm
steps:
#- id: files
# uses: jitterbit/get-changed-files@v1
#- run: |
# for changed_file in ${{ steps.files.outputs.all }}; do
# echo "Do something with this ${changed_file}."
# done
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.11.0
- name: Add repos
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.5.0
env:
CR_SKIP_EXISTING: true
CR_TOKEN: "${{ secrets.PAT }}"