-
Notifications
You must be signed in to change notification settings - Fork 1.1k
135 lines (117 loc) · 4.64 KB
/
Copy pathauto-update-otel-sdk.yml
File metadata and controls
135 lines (117 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Auto-update OpenTelemetry SDK
on:
schedule:
# hourly at minute 46
- cron: "46 * * * *"
workflow_dispatch:
permissions:
contents: read
jobs:
check-versions:
runs-on: ubuntu-latest
outputs:
current-version: ${{ steps.check-versions.outputs.current-version }}
latest-version: ${{ steps.check-versions.outputs.latest-version }}
already-opened: ${{ steps.check-versions.outputs.already-opened }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- id: check-versions
name: Check versions
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
current_version=$(grep -Po "val otelSdkVersion = \"\K[0-9]+.[0-9]+.[0-9]+" \
dependencyManagement/build.gradle.kts)
latest_version=$(gh release view \
--repo open-telemetry/opentelemetry-java \
--json tagName \
--jq .tagName \
| sed 's/^v//')
matches=$(gh pr list \
--author app/otelbot \
--state open \
--search "in:title \"Update the OpenTelemetry SDK version to $latest_version\"")
if [ ! -z "$matches" ]
then
already_opened=true
fi
echo "current-version=$current_version" >> $GITHUB_OUTPUT
echo "latest-version=$latest_version" >> $GITHUB_OUTPUT
echo "already-opened=$already_opened" >> $GITHUB_OUTPUT
update-otel-sdk:
permissions:
contents: write # for git push to PR branch
runs-on: ubuntu-latest
if: |
needs.check-versions.outputs.current-version != needs.check-versions.outputs.latest-version &&
needs.check-versions.outputs.already-opened != 'true'
needs:
- check-versions
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Update version
env:
VERSION: ${{ needs.check-versions.outputs.latest-version }}
run: ./.github/scripts/update-sdk-version.sh $VERSION
- name: Free disk space
run: .github/scripts/gha-free-disk-space.sh
- name: Set up JDK for running Gradle
uses: actions/setup-java@0f481fcb613427c0f801b606911222b5b6f3083a # v5.5.0
with:
distribution: temurin
java-version-file: .java-version
- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0
- name: Update license report
# with the build cache enabled occasionally produces outdated results
run: ./gradlew generateLicenseReport --no-build-cache
- name: Undo license report clean
if: failure()
run: git checkout -- licenses
- name: Use CLA approved bot
run: .github/scripts/use-cla-approved-bot.sh
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
id: otelbot-token
with:
client-id: ${{ vars.OTELBOT_CLIENT_ID }}
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
permission-pull-requests: write
- name: Create pull request against main
if: success() || failure()
env:
VERSION: ${{ needs.check-versions.outputs.latest-version }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# pull requests from secrets.GITHUB_TOKEN do not run workflows
OTELBOT_TOKEN: ${{ steps.otelbot-token.outputs.token }}
run: |
gh auth setup-git
message="Update the OpenTelemetry SDK version to $VERSION"
body="Update the OpenTelemetry SDK version to \`$VERSION\`."
branch="otelbot/update-opentelemetry-sdk-to-${VERSION}"
git checkout -b $branch
git add -u
git add licenses
git commit -m "$message"
git push --set-upstream origin $branch
GH_TOKEN="$OTELBOT_TOKEN" gh pr create \
--title "$message" \
--body "$body" \
--base main
workflow-notification:
permissions:
issues: write
needs:
- check-versions
- update-otel-sdk
if: always()
uses: open-telemetry/shared-workflows/.github/workflows/workflow-failure-issue.yml@62d5939b47144252763c5ff9fffe8c20d76cd806 # v0.4.0
with:
success: >-
${{
needs.check-versions.result == 'success' &&
(needs.update-otel-sdk.result == 'success' || needs.update-otel-sdk.result == 'skipped')
}}