Skip to content

Commit

Permalink
chore: check dependencies [skip ci] (#10)
Browse files Browse the repository at this point in the history
* Move cr.yaml and ct.yaml on .github folder
  • Loading branch information
ialejandro authored Aug 13, 2024
1 parent 9700e97 commit 1fb5a6a
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 2 deletions.
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions .github/hack/prepare_body_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

DEFAULT_BASE_URL="https://github.com/bitnami/charts/releases/tag"
OPENSEARCH_BASE_URL="https://github.com/opensearch-project/helm-charts/releases/tag/opensearch"

awk -v default_base_url="$DEFAULT_BASE_URL" -v opensearch_base_url="$OPENSEARCH_BASE_URL" '
/^[a-zA-Z]/ {
if (name && show && current_version && new_version && current_version != new_version) {
base_url = (name == "opensearch") ? opensearch_base_url : default_base_url
print name "\n" dashes "\n\n* **Current**: `" current_version "`\n* **Upgrade**: `" new_version "`\n* **Changelog**: " base_url "/" name "/" new_version "\n"
}
name = $0;
getline; dashes = $0;
show = 1; # Reset show flag
current_version = ""; # Reset current_version
new_version = ""; # Reset new_version
}
/change detected:/ {
getline;
if (match($0, /updated from "([^"]+)" to "([^"]+)"/, versions)) {
current_version = versions[1];
new_version = versions[2];
}
}
/no change detected:/ {
show = 0; # Do not show this section
}
END {
if (name && show && current_version && new_version && current_version != new_version) {
base_url = (name == "opensearch") ? opensearch_base_url : default_base_url
print name "\n" dashes "\n\n* **Current**: `" current_version "`\n* **Upgrade**: `" new_version "`\n* Changelog: " base_url "/" name "/" new_version "\n"
}
}' "$1"
19 changes: 19 additions & 0 deletions .github/updatecli/helm-dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
sources:
oauth2proxy:
kind: helmchart
spec:
url: https://oauth2-proxy.github.io/manifests/
name: oauth2proxy
versionFilter:
kind: semver
pattern: '*' # replace with CI/CD updatecli
sourceid: oauth2proxy
conditions: {}
targets:
oauth2proxy:
name: bump chart dependencies
kind: yaml
spec:
file: charts/Chart.yaml
key: $.dependencies[0].version
sourceid: oauth2proxy
83 changes: 83 additions & 0 deletions .github/workflows/check-steampipe-major-dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Check Steampipe major dependencies releases

on:
workflow_dispatch:
schedule:
- cron: '0 0 1 * *' # first day of month

jobs:
check-and-update-major-dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Prepare updatecli configuration
id: dependencies
run: |
# get name dependencies
dependencies=($(yq eval -o=json '.dependencies[] | .name' charts/Chart.yaml | xargs))
# replace version
for dependency in "${dependencies[@]}"; do
yq eval -i ".sources.${dependency}.spec.versionFilter.pattern = \"*\"" .github/updatecli/helm-dependencies.yaml
done
- name: Install updatecli
uses: updatecli/updatecli-action@v2

- name: Update dependencies
run: |
updatecli apply --config .github/updatecli/helm-dependencies.yaml --commit=false 2>&1 | tee > $GITHUB_WORKSPACE/tmp-major-output.log
awk '/TARGETS/{flag=1;next}/ACTIONS/{flag=0}flag' $GITHUB_WORKSPACE/tmp-major-output.log > $GITHUB_WORKSPACE/clean-major-output.log
chmod +x .github/hack/prepare_body_pr.sh
$GITHUB_WORKSPACE/.github/hack/prepare_body_pr.sh $GITHUB_WORKSPACE/clean-major-output.log > $GITHUB_WORKSPACE/major-output.log
# show PR body
cat major-output.log
shell: bash
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Update README.md Helm Chart
uses: losisin/helm-docs-github-action@v1
with:
chart-search-root: charts

- name: Get current date
id: date
run: |
echo "date=$(date -I)" >> $GITHUB_OUTPUT
- name: Create PR with changes (dry-run)
uses: peter-evans/create-pull-request@v6
if: github.event_name == 'workflow_dispatch'
with:
add-paths: charts
token: ${{ secrets.PAT_GITHUB }}
commit-message: "fix: update major dependencies version"
signoff: false
branch: fix/upgrade-steampipe-major-dependencies-${{ steps.date.outputs.date }}
delete-branch: true
title: '[steampipe] upgrade major dependencies (${{ steps.date.outputs.date }})'
body-path: major-output.log
draft: true
labels: |
auto-pr-bump-version
- name: Create PR with changes
uses: peter-evans/create-pull-request@v6
if: github.event_name == 'schedule'
with:
add-paths: charts
token: ${{ secrets.PAT_GITHUB }}
commit-message: "fix: update major dependencies version"
signoff: false
branch: fix/upgrade-steampipe-major-dependencies-${{ steps.date.outputs.date }}
delete-branch: true
title: '[steampipe] upgrade major dependencies (${{ steps.date.outputs.date }})'
body-path: major-output.log
labels: |
auto-pr-bump-version
85 changes: 85 additions & 0 deletions .github/workflows/check-steampipe-minor-dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Check Steampipe minor dependencies releases

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' # every monday

jobs:
check-and-update-minor-dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Prepare updatecli configuration
id: dependencies
run: |
# get name dependencies
dependencies=($(yq eval -o=json '.dependencies[] | .name' charts/Chart.yaml | xargs))
# replace version
for dependency in "${dependencies[@]}"; do
version="~$(yq eval -r ".dependencies[] | select(.name == \"${dependency}\") | .version" charts/Chart.yaml | cut -d'.' -f1)"
yq eval -i ".sources.${dependency}.spec.versionFilter.pattern = \"${version}\"" .github/updatecli/helm-dependencies.yaml
done
- name: Install updatecli
uses: updatecli/updatecli-action@v2

- name: Update dependencies
run: |
updatecli apply --config .github/updatecli/helm-dependencies.yaml --commit=false 2>&1 | tee > $GITHUB_WORKSPACE/tmp-minor-output.log
awk '/TARGETS/{flag=1;next}/ACTIONS/{flag=0}flag' $GITHUB_WORKSPACE/tmp-minor-output.log > $GITHUB_WORKSPACE/clean-minor-output.log
chmod +x .github/hack/prepare_body_pr.sh
$GITHUB_WORKSPACE/.github/hack/prepare_body_pr.sh $GITHUB_WORKSPACE/clean-minor-output.log > $GITHUB_WORKSPACE/minor-output.log
# show PR body
cat minor-output.log
shell: bash
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Update README.md Helm Chart
uses: losisin/helm-docs-github-action@v1
with:
chart-search-root: charts

- name: Get current date
id: date
run: |
echo "date=$(date -I)" >> $GITHUB_OUTPUT
- name: Create PR with changes (dry-run)
uses: peter-evans/create-pull-request@v6
if: github.event_name == 'workflow_dispatch'
with:
add-paths: charts
token: ${{ secrets.PAT_GITHUB }}
commit-message: "fix: update minor dependencies version"
signoff: false
branch: fix/upgrade-steampipe-minor-dependencies-${{ steps.date.outputs.date }}
delete-branch: true
title: '[steampipe] upgrade minor dependencies (${{ steps.date.outputs.date }})'
body-path: minor-output.log
draft: true
labels: |
auto-pr-bump-version
- name: Create PR with changes
uses: peter-evans/create-pull-request@v6
if: github.event_name == 'schedule'
with:
add-paths: charts
token: ${{ secrets.PAT_GITHUB }}
commit-message: "fix: update minor dependencies version"
signoff: false
branch: fix/upgrade-steampipe-minor-dependencies-${{ steps.date.outputs.date }}
delete-branch: true
title: '[steampipe] upgrade minor dependencies (${{ steps.date.outputs.date }})'
body-path: minor-output.log
labels: |
auto-pr-bump-version
2 changes: 1 addition & 1 deletion .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
uses: helm/kind-action@v1

- name: Run chart-testing (lint-and-install)
run: ct lint-and-install --config ct.yaml
run: ct lint-and-install --config .github/ct.yaml
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
uses: helm/chart-releaser-action@v1.6.0
with:
charts_dir: ./
config: cr.yaml
config: .github/cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_SKIP_EXISTING: true
Expand Down

0 comments on commit 1fb5a6a

Please sign in to comment.