Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-update more versions #2351

Merged
merged 8 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .github/workflows/auto-update-collector-version.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/auto-update-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Auto-update versions

on:
workflow_dispatch:
schedule:
# hourly at minute 10
- cron: "10 * * * *"

jobs:
auto-update-versions:
name: Auto-update versions
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use CLA approved github bot
run: |
git config user.name opentelemetrybot
git config user.email 107717825+opentelemetrybot@users.noreply.github.com

- name: Auto-update
run: |
./.github/workflows/scripts/auto-update-version.sh "opentelemetry-collector-releases" "collectorVersion" "content/en/docs/collector/_index.md"
trask marked this conversation as resolved.
Show resolved Hide resolved
./.github/workflows/scripts/auto-update-version.sh "opentelemetry-java" "javaVersion" "content/en/docs/instrumentation/java/_index.md" "content/en/docs/instrumentation/java/manual.md"
trask marked this conversation as resolved.
Show resolved Hide resolved
env:
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
40 changes: 40 additions & 0 deletions .github/workflows/scripts/auto-update-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash -e

repo=$1
variable_name=$2
file_names=("${@:3}") # remaining args
chalin marked this conversation as resolved.
Show resolved Hide resolved

latest_version=$(gh api -q .tag_name "repos/open-telemetry/$repo/releases/latest" | sed 's/^v//')

echo "Repo: $repo"
echo "Latest version: $latest_version"

for file_name in "${file_names[@]}"
do
sed -i -e "s/$variable_name: .*/$variable_name: $latest_version/" "$file_name"
trask marked this conversation as resolved.
Show resolved Hide resolved
done

if git diff --quiet; then
echo "Already at the latest version."
exit 0
fi

message="Update $repo version to $latest_version"
body="Update $repo version to \`$latest_version\`."
trask marked this conversation as resolved.
Show resolved Hide resolved

existing_pr_count=$(gh pr list --state all --search "in:title $message" | wc -l)
if [ "$existing_pr_count" -gt 0 ]; then
echo "PR for this version was already created."
trask marked this conversation as resolved.
Show resolved Hide resolved
exit 0
fi

branch="opentelemetrybot/auto-update-$repo-$latest_version"
chalin marked this conversation as resolved.
Show resolved Hide resolved

git checkout -b "$branch"
git commit -a -m "$message"
git push --set-upstream origin "$branch"

echo "Creating a pull request on your behalf."
trask marked this conversation as resolved.
Show resolved Hide resolved
gh pr create --label auto-update \
--title "$message" \
--body "$body"
78 changes: 0 additions & 78 deletions .github/workflows/scripts/check-collector-version.sh

This file was deleted.