Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
jvoravong committed Sep 22, 2023
1 parent 1ed56cf commit 484f37e
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 19 deletions.
1 change: 0 additions & 1 deletion .github/workflows/update_chart_dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@ jobs:
branch: "update-${{ matrix.repo }}-${{ steps.update_chart.outputs.LATEST_VER }}"
base: main
delete-branch: true
modify-outputs: false
17 changes: 15 additions & 2 deletions .github/workflows/update_instrumentation_dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,20 @@ jobs:
commit-message: Update ${{ matrix.language }} instrumentation version
title: Update ${{ matrix.language }} instrumentation version to ${{ steps.swizzle_version.outputs.TAG_UPSTREAM }}
body: Use the new version of the ${{ matrix.language }} instrumentation
branch: "update-${{ matrix.language }}-${{ steps.swizzle_version.outputs.TAG_UPSTREAM }}"
branch: "update-${{ matrix.language }}"
base: main
delete-branch: true
modify-outputs: false
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
committer: "GitHub <noreply@github.com>"
- name: Add CHANGELOG entry
if: ${{ steps.swizzle_version.outputs.NEED_UPDATE == 1 }}
run: |
git fetch origin
git checkout "update-${{ matrix.language }}-${{ steps.swizzle_version.outputs.TAG_UPSTREAM }}"
PR_ID=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository }}:update-${{ matrix.language }}-${{ steps.swizzle_version.outputs.TAG_UPSTREAM }} | jq '.[0].id')
make chlog-new CHANGE_TYPE=enhancement COMPONENT=operator \
NOTE="Update ${{ matrix.language }} instrumentation version to ${{ steps.swizzle_version.outputs.TAG_UPSTREAM }}" \
ISSUES="[$PR_ID]"
git
git commit -m "Add .chloggen entry"
git push origin main
2 changes: 1 addition & 1 deletion ci_scripts/chloggen-new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# Include the base utility functions for setting and debugging variables
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/base_util.sh"
source "$SCRIPT_DIR/common.sh"

# ---- Initialize Variables ----
if [[ -z "$FILENAME" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion ci_scripts/chloggen-pr-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# Include the base utility functions for setting and debugging variables
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/base_util.sh"
source "$SCRIPT_DIR/common.sh"

# ---- Initialize Variables ----
# Get the current branch name
Expand Down
2 changes: 1 addition & 1 deletion ci_scripts/chloggen-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Include the base utility functions for setting and debugging variables
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/base_util.sh"
source "$SCRIPT_DIR/common.sh"

# ---- Initialize Variables ----
# Create a temporary file to hold the updated CHANGELOG.md content
Expand Down
16 changes: 16 additions & 0 deletions ci_scripts/base_util.sh → ci_scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,19 @@ emit_output() {
echo "${var_name}=${var_value}"
fi
}

# ---- CI/CD Methods ----
# Function: setup_git
# Description: Configures git with predefined user name and email.
# Designed to be used in a GitHub workflow environment.
# Usage: setup_git
setup_git() {
# Check if the function is being run in a GitHub workflow environment
if [[ -z "$GITHUB_ACTIONS" ]]; then
debug "Skipping setup git config"
else
git config --global user.name "release-bot"
git config --global user.email "ssg-srv-gh-o11y-gdi@splunk.com"
echo "Successfully setup git config for release-bot"
fi
}
2 changes: 1 addition & 1 deletion ci_scripts/install-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# Include the base utility functions for setting and debugging variables
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/base_util.sh"
source "$SCRIPT_DIR/common.sh"

# ---- Initialize Variables and Functions ----
# Default to true if running in a GitHub workflow, false otherwise
Expand Down
12 changes: 7 additions & 5 deletions ci_scripts/update-images-operator-otel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# Include the base utility functions for setting and debugging variables
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/base_util.sh"
source "$SCRIPT_DIR/common.sh"

# ---- Initialize Temporary Files ----
# Create a temporary file to hold a subsection of the values.yaml file
Expand Down Expand Up @@ -76,9 +76,6 @@ while IFS='=' read -r IMAGE_KEY VERSION; do
fi
done < "${TEMP_VERSIONS}"

# Emit the NEED_UPDATE variable to either GitHub output or stdout
emit_output "NEED_UPDATE"

# Merge the updated subsection back into values.yaml
# This approach specifically updates only the subsection between the start and end tokens.
# By doing so, we avoid reformatting the entire file, thus preserving the original structure and comments.
Expand All @@ -87,12 +84,17 @@ awk '
/# Auto-instrumentation Libraries \(Start\)/ {p=1; print $0; next}
/# Auto-instrumentation Libraries \(End\)/ {p=0; while((getline line < "'$TEMP_VALUES_FILE'") > 0) printf " %s\n", line; print $0; next}
' "$VALUES_FILE_PATH" > "${VALUES_FILE_PATH}.updated"

# Replace the original values.yaml with the updated version
mv "${VALUES_FILE_PATH}.updated" "$VALUES_FILE_PATH"
# Cleanup temporary files
rm "$TEMP_VALUES_FILE"
rm "$TEMP_VERSIONS"


# Emit the NEED_UPDATE variable to either GitHub output or stdout
emit_output "NEED_UPDATE"
# If in a CI/CD pipeline, setup git config for the bot user
setup_git

echo "Image update process completed successfully!"
exit 0
26 changes: 19 additions & 7 deletions ci_scripts/update-images-operator-splunk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Include the base utility functions for setting and debugging variables
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/base_util.sh"
source "$SCRIPT_DIR/common.sh"

# ---- Validate Input Arguments ----
# Check for command-line arguments
Expand All @@ -27,6 +27,8 @@ fi
# ---- Initialize Variables ----
# Set the instrumentation library name
setd "INST_LIB_NAME" "$1"
# Create a temporary file to hold a subsection of the values.yaml file
setd "TEMP_VALUES_FILE" "$SCRIPT_DIR/temp_values_subsection.yaml"

# Set repository-related variables
setd "REPO" "ghcr.io/${OWNER}/splunk-otel-${INST_LIB_NAME}/splunk-otel-${INST_LIB_NAME}"
Expand All @@ -47,19 +49,29 @@ echo "${REPOSITORY_LOCAL} -> Local tag: ${TAG_LOCAL}, Latest tag: $TAG_UPSTREAM"

# ---- Update Version Information ----
# If needed, update the tag version in values.yaml
setd "NEED_UPDATE" "${NEED_UPDATE:-0}" # Sets NEED_UPDATE to its current value or 0 if not set
if [ "$TAG_UPSTREAM" == "$TAG_LOCAL" ]; then
echo "We are already up to date. Nothing else to do."
elif [[ -z "$TAG_LOCAL" || "$TAG_LOCAL" == "null" || "$TAG_LOCAL" != "$TAG_UPSTREAM" ]]; then
echo "We are not up to date. Updating now."
setd "NEED_UPDATE" 1 # Setting NEED_UPDATE to 1 as an update is required
exit 0
fi
echo "We are not up to date. Updating now."
setd "NEED_UPDATE" 1

# ---- Extract Subsection for Update ----
# Extract the content between "# Auto-instrumentation Libraries (Start)" and "# Auto-instrumentation Libraries (End)"
awk '/# Auto-instrumentation Libraries \(Start\)/,/# Auto-instrumentation Libraries \(End\)/' "$VALUES_FILE_PATH" | grep -v "# Auto-instrumentation Libraries " > "$TEMP_VALUES_FILE"
emit_output "TAG_LOCAL"
emit_output "TAG_UPSTREAM"
yq eval -i ".${TAG_LOCAL_PATH} = \"$TAG_UPSTREAM\"" "${VALUES_FILE_PATH}"
fi
yq eval -i ".${TAG_LOCAL_PATH} = \"$TAG_UPSTREAM\"" "${TEMP_VALUES_FILE}"
# Replace the original values.yaml with the updated version
mv "${VALUES_FILE_PATH}.updated" "$VALUES_FILE_PATH"
# Cleanup temporary files
rm "$TEMP_VALUES_FILE"
rm "$TEMP_VERSIONS"

# Emit the NEED_UPDATE variable to either GitHub output or stdout
emit_output "NEED_UPDATE"
# If in a CI/CD pipeline, setup git config for the bot user
setup_git

echo "Image update process completed successfully!"
exit 0

0 comments on commit 484f37e

Please sign in to comment.