Check Latest ZWAVE-JS-UI #709
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}" |