From cea9f3c90f8455d586c454f6190d1a7b9cb7bce2 Mon Sep 17 00:00:00 2001 From: Victor Carlos Erenu Date: Thu, 23 Apr 2026 01:53:56 +0700 Subject: [PATCH 1/5] Add revert option into bumper workflow --- .github/workflows/5_bumper_repository.yml | 76 +++++++++++++++++++++-- 1 file changed, 70 insertions(+), 6 deletions(-) diff --git a/.github/workflows/5_bumper_repository.yml b/.github/workflows/5_bumper_repository.yml index 39464ad7..6feaccb0 100644 --- a/.github/workflows/5_bumper_repository.yml +++ b/.github/workflows/5_bumper_repository.yml @@ -32,7 +32,11 @@ on: description: 'Optional identifier for the run' required: false type: string - + revert: + description: 'Set to true to revert the bump changes applied for this issue' + default: false + required: false + type: boolean jobs: bump: name: Repository bumper 5.x @@ -107,7 +111,14 @@ jobs: fi issue_number=$(echo "${{ inputs.issue-link }}" | awk -F'/' '{print $NF}') - BRANCH_NAME="enhancement/wqa${issue_number}-bump-${{ github.ref_name }}" + + if [[ "${{ inputs.revert }}" == "true" ]]; then + BRANCH_NAME="enhancement/wqa${issue_number}-revert-bump-${{ github.ref_name }}" + echo "pr_title=Revert bump ${{ github.ref_name }} branch" >> $GITHUB_OUTPUT + else + BRANCH_NAME="enhancement/wqa${issue_number}-bump-${{ github.ref_name }}" + echo "pr_title=Bump ${{ github.ref_name }} branch" >> $GITHUB_OUTPUT + fi echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT echo "script_params=${script_params}" >> $GITHUB_OUTPUT @@ -116,22 +127,64 @@ jobs: git checkout -b ${{ steps.vars.outputs.branch_name }} - name: Make version bump changes + if: inputs.revert != true run: | echo "Running bump script" bash ${{ env.BUMP_SCRIPT_PATH }} ${{ steps.vars.outputs.script_params }} - - name: Commit and push changes + - name: Commit changes (Bump) + if: inputs.revert != true run: | git add . git commit -m "feat: bump ${{ github.ref_name }}" + + - name: Revert references (Revert) + id: revert_step + if: inputs.revert == true + run: | + ISSUE_NUMBER=$(echo "${{ inputs.issue-link }}" | awk -F'/' '{print $NF}') + + BUMP_BRANCH="enhancement/wqa${ISSUE_NUMBER}-bump-${{ github.ref_name }}" + + PR_NUMBER=$(gh pr list --head "$BUMP_BRANCH" --base "${{ github.ref_name }}" --state merged --json number --jq '.[0].number') + + if [ -z "$PR_NUMBER" ] || [ "$PR_NUMBER" == "null" ]; then + echo "Error: The original PR for the bump was not found" + echo "Searching merged PR from: $BUMP_BRANCH to ${{ github.ref_name }}" + exit 1 + fi + + echo "Original PR found: #$PR_NUMBER" + + MERGE_COMMIT=$(gh pr view $PR_NUMBER --json mergeCommit --jq '.mergeCommit.oid') + + git revert -m 1 $MERGE_COMMIT --no-commit + + # Remove the files to prevent them from being included in the revert commit + git checkout HEAD -- VERSION.json 2>/dev/null || true + git checkout HEAD -- CHANGELOG.md 2>/dev/null || true + # Add any other repository-specific version files here + + if git diff --staged --quiet; then + echo "No references to revert. Skipping commit." + echo "has_changes=false" >> $GITHUB_OUTPUT + else + git commit -m "feat: revert ${{ github.ref_name }} references" + echo "has_changes=true" >> $GITHUB_OUTPUT + fi + + - name: Push changes + if: inputs.revert != true || (inputs.revert == true && steps.revert_step.outputs.has_changes == 'true') + run: | git push origin ${{ steps.vars.outputs.branch_name }} - name: Create pull request id: create_pr + if: inputs.revert != true || (inputs.revert == true && steps.revert_step.outputs.has_changes == 'true') run: | gh auth setup-git PR_URL=$(gh pr create \ - --title "Bump ${{ github.ref_name }} branch" \ + --title "${{ steps.vars.outputs.pr_title }}" \ --body "Issue: ${{ inputs.issue-link }}" \ --base ${{ github.ref_name }} \ --head ${{ steps.vars.outputs.branch_name }}) @@ -140,14 +193,25 @@ jobs: echo "pull_request_url=${PR_URL}" >> $GITHUB_OUTPUT - name: Merge pull request + if: inputs.revert != true || (inputs.revert == true && steps.revert_step.outputs.has_changes == 'true') run: | - # Any checks for the PR are bypassed since the branch is expected to be functional (i.e. the bump process does not introduce any bugs) + # Any checks for the PR are bypassed since the branch is expected to be functional gh pr merge "${{ steps.create_pr.outputs.pull_request_url }}" --merge --admin - name: Show logs + if: inputs.revert != true run: | echo "Bump complete." echo "Branch: ${{ steps.vars.outputs.branch_name }}" echo "PR: ${{ steps.create_pr.outputs.pull_request_url }}" echo "Bumper scripts logs:" - cat ${BUMP_LOG_PATH}/repository_bumper*log \ No newline at end of file + cat ${BUMP_LOG_PATH}/repository_bumper*log + + - name: Show revert logs + if: inputs.revert == true + run: | + echo "Revert bump complete." + echo "Branch: ${{ steps.vars.outputs.branch_name }}" + echo "PR: ${{ steps.create_pr.outputs.pull_request_url }}" + echo "Revert bumper scripts logs:" + cat ${BUMP_LOG_PATH}/repository_bumper*log || true \ No newline at end of file From 56c73be50ce1fc0b2f17af26db759c80aa1409c8 Mon Sep 17 00:00:00 2001 From: Victor Carlos Erenu Date: Thu, 23 Apr 2026 02:52:33 +0700 Subject: [PATCH 2/5] Add step for fetch full history into revert path --- .github/workflows/5_bumper_repository.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/5_bumper_repository.yml b/.github/workflows/5_bumper_repository.yml index 6feaccb0..6a13ff4d 100644 --- a/.github/workflows/5_bumper_repository.yml +++ b/.github/workflows/5_bumper_repository.yml @@ -138,6 +138,10 @@ jobs: git add . git commit -m "feat: bump ${{ github.ref_name }}" + - name: Fetch full history (Revert) + if: inputs.revert == true + run: git fetch --unshallow + - name: Revert references (Revert) id: revert_step if: inputs.revert == true From 6087f14835f1317663228095acf86b59b8c2f43f Mon Sep 17 00:00:00 2001 From: Victor Carlos Erenu Date: Thu, 23 Apr 2026 14:37:58 +0700 Subject: [PATCH 3/5] Add changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9ca6cb5..d7aa8a30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ All notable changes to this project will be documented in this file. ### Changed -- Add checks for artifact_urls.yaml download ([#2315](https://github.com/wazuh/wazuh-docker/pull/2315)) +- Add revert option into bumper workflow ([#2330](https://github.com/wazuh/wazuh-docker/pull/2330)) - Add set_as_main option ([#2293](https://github.com/wazuh/wazuh-docker/pull/2293)) - Adapt bumper workflows to change main branch ([#2294](https://github.com/wazuh/wazuh-docker/pull/2294)) - Delete all API user and password references and Wazuh agent references ([#2289](https://github.com/wazuh/wazuh-docker/pull/2289)) From 3adc3aedd556a6a49a9cd096ae3112a37b0e88a2 Mon Sep 17 00:00:00 2001 From: Victor Carlos Erenu Date: Thu, 23 Apr 2026 15:18:17 +0700 Subject: [PATCH 4/5] Recover deleted changelog --- .github/workflows/5_bumper_repository.yml | 2 +- CHANGELOG.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/5_bumper_repository.yml b/.github/workflows/5_bumper_repository.yml index 6a13ff4d..f92c9f2c 100644 --- a/.github/workflows/5_bumper_repository.yml +++ b/.github/workflows/5_bumper_repository.yml @@ -218,4 +218,4 @@ jobs: echo "Branch: ${{ steps.vars.outputs.branch_name }}" echo "PR: ${{ steps.create_pr.outputs.pull_request_url }}" echo "Revert bumper scripts logs:" - cat ${BUMP_LOG_PATH}/repository_bumper*log || true \ No newline at end of file + cat ${BUMP_LOG_PATH}/repository_bumper*log || true diff --git a/CHANGELOG.md b/CHANGELOG.md index d7aa8a30..1e1d7ed9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. ### Changed - Add revert option into bumper workflow ([#2330](https://github.com/wazuh/wazuh-docker/pull/2330)) +- Add checks for artifact_urls.yaml download ([#2315](https://github.com/wazuh/wazuh-docker/pull/2315)) - Add set_as_main option ([#2293](https://github.com/wazuh/wazuh-docker/pull/2293)) - Adapt bumper workflows to change main branch ([#2294](https://github.com/wazuh/wazuh-docker/pull/2294)) - Delete all API user and password references and Wazuh agent references ([#2289](https://github.com/wazuh/wazuh-docker/pull/2289)) From 158aedd9896740e05f5d80d2e6b9f5046f7f1551 Mon Sep 17 00:00:00 2001 From: Victor Carlos Erenu Date: Fri, 24 Apr 2026 18:53:40 +0700 Subject: [PATCH 5/5] Move changelog entries --- CHANGELOG.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e1d7ed9..188d35aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,12 @@ All notable changes to this project will be documented in this file. ### Added -- None - -### Changed - - Add revert option into bumper workflow ([#2330](https://github.com/wazuh/wazuh-docker/pull/2330)) - Add checks for artifact_urls.yaml download ([#2315](https://github.com/wazuh/wazuh-docker/pull/2315)) - Add set_as_main option ([#2293](https://github.com/wazuh/wazuh-docker/pull/2293)) + +### Changed + - Adapt bumper workflows to change main branch ([#2294](https://github.com/wazuh/wazuh-docker/pull/2294)) - Delete all API user and password references and Wazuh agent references ([#2289](https://github.com/wazuh/wazuh-docker/pull/2289)) - Create certificate directory with default user and group ([#2287](https://github.com/wazuh/wazuh-docker/pull/2287))