From bd472187ab2fcbc80eac049686144f25b283a841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Alejandro=20Marug=C3=A1n?= Date: Fri, 2 Aug 2024 16:38:27 +0200 Subject: [PATCH] chore: add workflow to check updates --- .github/workflows/auto-assign.yaml | 13 +++--- .github/workflows/check-changes.yaml | 69 ++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/check-changes.yaml diff --git a/.github/workflows/auto-assign.yaml b/.github/workflows/auto-assign.yaml index 9c6a5a6..72900b1 100644 --- a/.github/workflows/auto-assign.yaml +++ b/.github/workflows/auto-assign.yaml @@ -10,10 +10,11 @@ jobs: permissions: issues: write pull-requests: write + steps: - - name: 'Auto-assign issue' - uses: pozil/auto-assign-issue@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - assignees: ialejandro - numOfAssignee: 1 + - name: 'Auto-assign issue' + uses: pozil/auto-assign-issue@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + assignees: ialejandro + numOfAssignee: 1 diff --git a/.github/workflows/check-changes.yaml b/.github/workflows/check-changes.yaml new file mode 100644 index 0000000..d0780b6 --- /dev/null +++ b/.github/workflows/check-changes.yaml @@ -0,0 +1,69 @@ +name: Check OpenCTI updates + +on: + workflow_dispatch: + schedule: + - cron: '0 * * * *' + +jobs: + check-and-release: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get latest version + id: latest_version + run: | + # latest + latest_version=$(curl -s https://api.github.com/repos/opencti-platform/opencti/tags | jq -r '.[0].name') + echo "latest_version=$latest_version" >> $GITHUB_OUTPUT + + - name: Get current appVersion + id: current_version + run: | + # current + current_version=$(grep appVersion opencti/Chart.yaml | awk '{ print $2 }') + echo "current_version=$current_version" >> $GITHUB_OUTPUT + + - name: Check if exists changes + id: check_changes + run: | + # check changes + if [ ${{ steps.latest_version.outputs.latest_version }} != ${{ steps.current_version.outputs.current_version }} ]; then + echo "version_changed=true" >> $GITHUB_OUTPUT + fi + + - name: Update appVersion + if: steps.check_changes.outputs.version_changed == 'true' + run: | + # update appVersion + sed -i "s/appVersion: .*/appVersion: ${{ steps.latest_version.outputs.latest_version }}/g" opencti/Chart.yaml + + - name: Update helm chart README.md + uses: losisin/helm-docs-github-action@v1 + with: + chart-search-root: opencti + + - name: Create Pull Request + if: steps.check_changes.outputs.version_changed == 'true' + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHB_PERSONAL_TOKEN }} + commit-message: "fix: bump OpenCTI version to ${{ steps.latest_version.outputs.latest_version }}" + signoff: true + branch: fix/upgrade-opencti-appversion-${{ steps.latest_version.outputs.latest_version }} + delete-branch: true + title: '[opencti] Bump version to ${{ steps.latest_version.outputs.latest_version }}' + body: | + Bump OpenCTI version: + - :information_source: Current: `${{ steps.current_version.outputs.current_version }}` + - :up: Upgrade: `${{ steps.latest_version.outputs.latest_version }}` + + Changelog: https://github.com/OpenCTI-Platform/opencti/releases/tag/${{ steps.latest_version.outputs.latest_version }} + labels: | + auto-pr-bump-version + assignees: ialejandro + reviewers: ialejandro