forked from wazuh/wazuh-docker
Change bumper workflows
This commit is contained in:
@@ -14,11 +14,6 @@ on:
|
|||||||
default: ''
|
default: ''
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
tag:
|
|
||||||
description: 'Change branches references to tag-like references (e.g. v4.12.0-alpha7)'
|
|
||||||
default: false
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
issue-link:
|
issue-link:
|
||||||
description: 'Issue link in format https://github.com/wazuh/<REPO>/issues/<ISSUE-NUMBER>'
|
description: 'Issue link in format https://github.com/wazuh/<REPO>/issues/<ISSUE-NUMBER>'
|
||||||
required: true
|
required: true
|
||||||
@@ -81,18 +76,16 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
VERSION: ${{ inputs.version }}
|
VERSION: ${{ inputs.version }}
|
||||||
STAGE: ${{ inputs.stage }}
|
STAGE: ${{ inputs.stage }}
|
||||||
TAG: ${{ inputs.tag }}
|
|
||||||
run: |
|
run: |
|
||||||
script_params=""
|
script_params=""
|
||||||
version=${{ env.VERSION }}
|
version=${{ env.VERSION }}
|
||||||
stage=${{ env.STAGE }}
|
stage=${{ env.STAGE }}
|
||||||
tag=${{ env.TAG }}
|
|
||||||
|
|
||||||
# Both version and stage provided
|
# Both version and stage provided
|
||||||
if [[ -n "$version" && -n "$stage" && "$tag" != "true" ]]; then
|
if [[ -n "$version" && -n "$stage" ]]; then
|
||||||
script_params="--version ${version} --stage ${stage}"
|
script_params="--version ${version} --stage ${stage}"
|
||||||
elif [[ -n "$version" && -n "$stage" && "$tag" == "true" ]]; then
|
elif [[ -z "$version" && -n "$stage" ]]; then
|
||||||
script_params="--version ${version} --stage ${stage} --tag ${tag}"
|
script_params="--stage ${stage}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
issue_number=$(echo "${{ inputs.issue-link }}" | awk -F'/' '{print $NF}')
|
issue_number=$(echo "${{ inputs.issue-link }}" | awk -F'/' '{print $NF}')
|
||||||
|
|||||||
@@ -14,11 +14,6 @@ on:
|
|||||||
default: ''
|
default: ''
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
tag:
|
|
||||||
description: 'Change branches references to tag-like references (e.g. v4.12.0-alpha7)'
|
|
||||||
default: false
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
set_as_main:
|
set_as_main:
|
||||||
description: "Enable main branch mode: bump version values only, keep branch references pointing to main"
|
description: "Enable main branch mode: bump version values only, keep branch references pointing to main"
|
||||||
required: false
|
required: false
|
||||||
@@ -81,28 +76,27 @@ jobs:
|
|||||||
# doesn't have all the necessary permissions
|
# doesn't have all the necessary permissions
|
||||||
token: ${{ env.GH_TOKEN }}
|
token: ${{ env.GH_TOKEN }}
|
||||||
|
|
||||||
- name: Determine branch name and script params
|
- name: Determine branch name
|
||||||
id: vars
|
id: vars
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ inputs.version }}
|
VERSION: ${{ inputs.version }}
|
||||||
STAGE: ${{ inputs.stage }}
|
STAGE: ${{ inputs.stage }}
|
||||||
TAG: ${{ inputs.tag }}
|
|
||||||
run: |
|
run: |
|
||||||
script_params=""
|
script_params=""
|
||||||
version=${{ env.VERSION }}
|
version=${{ env.VERSION }}
|
||||||
stage=${{ env.STAGE }}
|
stage=${{ env.STAGE }}
|
||||||
tag=${{ env.TAG }}
|
|
||||||
set_as_main=${{ inputs.set_as_main }}
|
set_as_main=${{ inputs.set_as_main }}
|
||||||
|
|
||||||
# Both version and stage provided
|
if [[ "$set_as_main" == "true" ]]; then
|
||||||
if [[ -n "$version" && -n "$stage" && "$tag" != "true" ]]; then
|
script_params="--set-as-main"
|
||||||
script_params="--version ${version} --stage ${stage}"
|
|
||||||
elif [[ -n "$version" && -n "$stage" && "$tag" == "true" ]]; then
|
|
||||||
script_params="--version ${version} --stage ${stage} --tag ${tag}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$set_as_main" == "true" ]]; then
|
# Both version and stage provided
|
||||||
script_params="${script_params} --set-as-main"
|
if [[ -n "$version" && -n "$stage" ]]; then
|
||||||
|
script_params+=" --version ${version} --stage ${stage}"
|
||||||
|
elif [[ -z "$version" && -n "$stage" ]]; then
|
||||||
|
script_params+=" --stage ${stage}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
issue_number=$(echo "${{ inputs.issue-link }}" | awk -F'/' '{print $NF}')
|
issue_number=$(echo "${{ inputs.issue-link }}" | awk -F'/' '{print $NF}')
|
||||||
@@ -119,18 +113,7 @@ jobs:
|
|||||||
echo "Running bump script"
|
echo "Running bump script"
|
||||||
bash ${{ env.BUMP_SCRIPT_PATH }} ${{ steps.vars.outputs.script_params }}
|
bash ${{ env.BUMP_SCRIPT_PATH }} ${{ steps.vars.outputs.script_params }}
|
||||||
|
|
||||||
- name: Check for file changes
|
|
||||||
id: changes
|
|
||||||
run: |
|
|
||||||
if git diff --quiet && git diff --cached --quiet; then
|
|
||||||
echo "No changes detected. Exiting cleanly."
|
|
||||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Commit and push changes
|
- name: Commit and push changes
|
||||||
if: steps.changes.outputs.has_changes == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
git add .
|
git add .
|
||||||
git commit -m "feat: bump ${{ github.ref_name }}"
|
git commit -m "feat: bump ${{ github.ref_name }}"
|
||||||
@@ -138,7 +121,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Create pull request
|
- name: Create pull request
|
||||||
id: create_pr
|
id: create_pr
|
||||||
if: steps.changes.outputs.has_changes == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
gh auth setup-git
|
gh auth setup-git
|
||||||
PR_URL=$(gh pr create \
|
PR_URL=$(gh pr create \
|
||||||
@@ -151,7 +133,6 @@ jobs:
|
|||||||
echo "pull_request_url=${PR_URL}" >> $GITHUB_OUTPUT
|
echo "pull_request_url=${PR_URL}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Merge pull request
|
- name: Merge pull request
|
||||||
if: steps.changes.outputs.has_changes == 'true'
|
|
||||||
run: |
|
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 (i.e. the bump process does not introduce any bugs)
|
||||||
gh pr merge "${{ steps.create_pr.outputs.pull_request_url }}" --merge --admin
|
gh pr merge "${{ steps.create_pr.outputs.pull_request_url }}" --merge --admin
|
||||||
@@ -159,11 +140,7 @@ jobs:
|
|||||||
- name: Show logs
|
- name: Show logs
|
||||||
run: |
|
run: |
|
||||||
echo "Bump complete."
|
echo "Bump complete."
|
||||||
if [[ "${{ steps.changes.outputs.has_changes }}" == "true" ]]; then
|
echo "Branch: ${{ steps.vars.outputs.branch_name }}"
|
||||||
echo "Branch: ${{ steps.vars.outputs.branch_name }}"
|
echo "PR: ${{ steps.create_pr.outputs.pull_request_url }}"
|
||||||
echo "PR: ${{ steps.create_pr.outputs.pull_request_url }}"
|
|
||||||
else
|
|
||||||
echo "No changes were made (no-op run)."
|
|
||||||
fi
|
|
||||||
echo "Bumper scripts logs:"
|
echo "Bumper scripts logs:"
|
||||||
cat ${BUMP_LOG_PATH}/repository_bumper*log
|
cat ${BUMP_LOG_PATH}/repository_bumper*log
|
||||||
Reference in New Issue
Block a user