Skip to content

Commit

Permalink
chore: improve PR body
Browse files Browse the repository at this point in the history
close #15
  • Loading branch information
ialejandro committed Aug 12, 2024
1 parent 06d5308 commit 5bd5097
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 5 deletions.
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"
29 changes: 26 additions & 3 deletions .github/workflows/check-opencti-major-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ jobs:

- name: Update dependencies
run: |
updatecli apply --config .github/updatecli/helm-dependencies.yaml --commit=false 2>&1 | tee > tmp-major-output.log
awk '/TARGETS/{flag=1;next}/ACTIONS/{flag=0}flag' tmp-major-output.log > major-output.log
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 }}"

Expand All @@ -45,12 +51,29 @@ jobs:
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/opencti
token: ${{ secrets.PAT_GITHUB }}
commit-message: "fix: update major dependencies version"
signoff: false
branch: fix/upgrade-opencti-major-dependencies-${{ steps.date.outputs.date }}
delete-branch: true
title: '[opencti] 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/opencti
token: ${{ secrets.PAT_GITHUB }}
commit-message: "fix: update mayor dependencies version"
commit-message: "fix: update major dependencies version"
signoff: false
branch: fix/upgrade-opencti-major-dependencies-${{ steps.date.outputs.date }}
delete-branch: true
Expand Down
28 changes: 26 additions & 2 deletions .github/workflows/check-opencti-minor-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ jobs:

- name: Update dependencies
run: |
updatecli apply --config .github/updatecli/helm-dependencies.yaml --commit=false 2>&1 | tee > tmp-minor-output.log
awk '/TARGETS/{flag=1;next}/ACTIONS/{flag=0}flag' tmp-minor-output.log > minor-output.log
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 }}"

Expand All @@ -46,8 +52,26 @@ jobs:
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/opencti
token: ${{ secrets.PAT_GITHUB }}
commit-message: "fix: update minor dependencies version"
signoff: false
branch: fix/upgrade-opencti-minor-dependencies-${{ steps.date.outputs.date }}
delete-branch: true
title: '[opencti] 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/opencti
token: ${{ secrets.PAT_GITHUB }}
Expand Down

0 comments on commit 5bd5097

Please sign in to comment.