-
Notifications
You must be signed in to change notification settings - Fork 5
80 lines (80 loc) · 3.16 KB
/
check_unifi.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
name: Check Latest UNIFI
on:
schedule:
- cron: '0 9 * * *'
env:
imagePath: 'jacobalberty/unifi'
containerRepo: 'jacobalberty/unifi'
registryIndex: 'https://index.docker.io'
registryAuth: 'https://auth.docker.io'
chartPath: 'charts/unifi'
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("^v[0-9]+[.][0-9]+[.][0-9]+$"))' |tail -1)
echo "newversion=$FOUNDVER" >> $GITHUB_OUTPUT
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: 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