Skip to content

[opentelemetry-integration] Add missing batch size to all recombine o… #71

[opentelemetry-integration] Add missing batch size to all recombine o…

[opentelemetry-integration] Add missing batch size to all recombine o… #71

name: Sync with integration-definitions
on:
push:
branches: [master]
paths:
- 'otel-integration/k8s-helm/Chart.yaml'
workflow_dispatch:
jobs:
Get_vesrion:
runs-on: ubuntu-latest
name: Get the new version
outputs:
Chart_version: "${{ steps.New_version.outputs.Chart_version }}"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get the new version
id: New_version
run: |
Chart_version=$(cat ./otel-integration/k8s-helm/Chart.yaml | grep "^version" | grep -oE '[^ ]+$')
echo "Chart_version=$Chart_version" >> $GITHUB_OUTPUT
commit_changes:
runs-on: ubuntu-latest
needs: Get_vesrion
steps:
- name: Checkout destination repository
uses: actions/checkout@v4
with:
repository: coralogix/integration-definitions
token: ${{ secrets.GH_TOKEN }}
- name: Check if version exists
id: version_exist
run: |
git fetch origin
template_version=${{ needs.Get_vesrion.outputs.Chart_version }}
if [ -d "./integrations/otel-agent-k8s/v$template_version" ]; then
echo "version exist"
echo "new_version_exist=true" >> $GITHUB_ENV
else
echo "new_version_exist=false" >> $GITHUB_ENV
echo "version Not exist"
fi
- name: Create files for the new version
if: "${{env.new_version_exist == 'false' || github.event_name == 'workflow_dispatch'}}"
run: |
branch_name="sync-telemetry-branch-$(date +"%m-%d-%H-%M")"
echo "branch_name=$branch_name" >> $GITHUB_ENV
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git checkout -b $branch_name
git pull origin master
git fetch origin
git push origin $branch_name
current_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
template_version=${{ needs.Get_vesrion.outputs.Chart_version }}
mkdir -p integrations/otel-agent-k8s/v${template_version}
last_version=$(grep "revision: " ./integrations/otel-agent-k8s/manifest.yaml | tail -n 1 | grep -oE '[^ ]+$')
cp integrations/otel-agent-k8s/v$last_version/commands.yaml integrations/otel-agent-k8s/v${template_version}/
cp integrations/otel-agent-k8s/v$last_version/fields.yaml integrations/otel-agent-k8s/v${template_version}/
cp integrations/otel-agent-k8s/v$last_version/integration_guide.yaml integrations/otel-agent-k8s/v${template_version}/
sed -i "s/--version=[^[:space:]]*/--version=$template_version/" integrations/otel-agent-k8s/v${template_version}/commands.yaml
if [ -f ./integrations/otel-agent-k8s/manifest.yaml ]; then
echo " - revision: ${template_version}
template:
type: HelmChart
commands: v${template_version}/commands.yaml
integration_guide: v${template_version}/integration_guide.yaml
field_definitions: v${template_version}/fields.yaml
published_at: $current_time" >> integrations/otel-agent-k8s/manifest.yaml
fi
git add .
merged_pr_from_telemetry_shipper=$(curl -s \
"https://api.github.com/repos/coralogix/telemetry-shippers/pulls?state=closed&base=master&sort=updated&direction=desc" \
| jq -r '.[0].title')
if [ "${{ github.event_name }}" == 'workflow_dispatch' ] || [ -z "$merged_pr_from_telemetry_shipper" ]; then
merged_pr_from_telemetry_shipper="sync-from-telemetry-shippers"
fi
echo "commit_message=$merged_pr_from_telemetry_shipper" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: commit change
if: "${{env.new_version_exist == 'false' || github.event_name == 'workflow_dispatch'}}"
uses: planetscale/[email protected]
with:
commit_message: ${{env.commit_message}}
repo: coralogix/integration-definitions
branch: ${{ env.branch_name }}
file_pattern: '*.yaml *.md'
env:
GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
- name: Create pull request
if: "${{ env.new_version_exist == 'false' || github.event_name == 'workflow_dispatch' }}"
run: |
# Fetch the latest closed pull request title
Pr_name=$(curl -s "https://api.github.com/repos/coralogix/telemetry-shippers/pulls?state=closed&base=master&sort=updated&direction=desc" \
| jq -r '.[0].title')
# Set a default title if running on workflow_dispatch or if no recent PR title is found
if [ -z "$Pr_name" ]; then
Pr_name="sync-from-telemetry-shippers"
fi
# Fetch the URL of the latest closed pull request
pr_url=$(curl -s \
"https://api.github.com/repos/coralogix/telemetry-shippers/pulls?state=closed&base=master&sort=updated&direction=desc" \
| jq -r '.[0].html_url')
# Fetch the body of the latest closed pull request
pr_body=$(curl -s \
"https://api.github.com/repos/coralogix/telemetry-shippers/pulls?state=closed&base=master&sort=updated&direction=desc" \
| jq -r '.[0].body')
# Set a default body if no recent PR body is found
if [ -z "$pr_body" ]; then
pr_body="This pull request syncs the changes from the telemetry-shippers repo to this repo. link to the original PR $pr_url"
else
pr_body="Link to the original PR: $pr_url $pr_body"
fi
# Create the new pull request with the title and body
gh pr create --base master --head "${{ env.branch_name }}" --title "${Pr_name}" --body "$pr_body"
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Merge pull request
if: "${{env.new_version_exist == 'false' || github.event_name == 'workflow_dispatch'}}"
run: |
check_status() {
gh pr checks ${{ env.branch_name }} --json state --jq 'all(.[]; .state == "SUCCESS")'
}
# Initialize the timeout variables
max_wait_time=$((10 * 60)) # 10 minutes in seconds
elapsed_time=0
sleep_interval=10 # Interval between checks in seconds
# Loop until all status checks are successful or timeout occurs
echo "Waiting for all status checks to pass..."
# Wait for 5 seconds before checking the status
sleep 5
while true; do
status=$(check_status)
if [ "$status" == "true" ]; then
echo "All status checks passed. Merging the pull request..."
break
fi
if [ "$elapsed_time" -ge "$max_wait_time" ]; then
echo "Timeout reached: Status checks did not pass within 10 minutes."
exit 1
fi
echo "Not all checks passed yet. Waiting for $sleep_interval seconds..."
sleep $sleep_interval
elapsed_time=$((elapsed_time + sleep_interval))
done
# Merge the pull request
gh pr merge --delete-branch --admin --squash ${{ env.branch_name }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}