Skip to content

Commit

Permalink
GitHub action must download correct otel4bash version according to it…
Browse files Browse the repository at this point in the history
…s own tag
  • Loading branch information
plengauer authored Apr 24, 2024
1 parent a0d4a86 commit 2c0f2f5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.6.0
4.6.1
11 changes: 11 additions & 0 deletions actions/instrument/job/inject_and_init.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
set -e

if [ -z "$GITHUB_ACTION_REPOSITORY" ]; then export GITHUB_ACTION_REPOSITORY="$GITHUB_REPOSITORY"; fi
action_tag_name="$(echo "$GITHUB_ACTION_REF" | cut -sd @ -f 2-)"
if [ -n "$action_tag_name" ]; then
debian_file="$(mktemp)"
curl "$GITHUB_API_URL"/repos/"$GITHUB_ACTION_REPOSITORY"/releases | { if [ "$action_tag_name" = main ]; then jq '.[0]'; else jq '.[] | select(.tag_name=="'"$action_tag_name"'")'; fi } | jq -r '.assets[] | .browser_download_url' | xargs wget -O "$debian_file"
sudo apt-get install -y "$debian_file"
rm "$debian_file"
else
wget -O - https://raw.githubusercontent.com/"$GITHUB_ACTION_REPOSITORY"/main/INSTALL.sh | sh -E
fi

root4job_end() {
if [ "$(curl "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/jobs" | jq -r ".jobs[] | select(.name==\"$GITHUB_JOB\") | select(.run_attempt==\"$GITHUB_RUN_ATTEMPT\") | .steps[] | select(.status==\"completed\") | select(.conclusion==\"failure\") | .name" | wc -l)" -gt 0 ]; then
otel_span_error "$span_handle"
Expand Down
3 changes: 1 addition & 2 deletions actions/instrument/job/inject_and_init.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ function run(executable, args = []) {
});
}

run('/bin/sh', [ '-c', 'wget -O - https://raw.githubusercontent.com/plengauer/opentelemetry-bash/main/INSTALL.sh | sh -E' ])
.then(() => run('/bin/bash', [ '-e', __dirname + '/inject_and_init.bash' ]))
run('/bin/bash', [ '-e', __dirname + '/inject_and_init.bash' ])
2 changes: 1 addition & 1 deletion actions/instrument/job/nop.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const process = require('process');
if (process.env['GITHUB_REPOSITORY'] == 'plengauer/opentelemetry-bash') {
if (!process.env['GITHUB_ACTION_REPOSITORY'] || process.env['GITHUB_REPOSITORY'] == process.env['GITHUB_ACTION_REPOSITORY']) {
// action is local and pre steps is not supported because the action needs to be checked out first and then its too let to execute a pre step
require('./inject_and_init.js');
}

0 comments on commit 2c0f2f5

Please sign in to comment.