1+ name : Nightly Upstream Snapshot Build
2+ description : This workflow checks for new upstream versions of OpenTelemetry dependencies, creates a PR to update them, and builds and tests the new changes.
3+
4+ on :
5+ schedule :
6+ - cron : " 21 3 * * *"
7+ workflow_dispatch :
8+
9+ env :
10+ AWS_DEFAULT_REGION : us-east-1
11+ BRANCH_NAME : nightly-dependency-updates
12+
13+ permissions :
14+ id-token : write
15+ contents : write
16+ pull-requests : write
17+
18+ jobs :
19+ update-dependencies :
20+ runs-on : ubuntu-latest
21+ outputs :
22+ has_changes : ${{ steps.check_changes.outputs.has_changes }}
23+ otel_python_version : ${{ steps.get_versions.outputs.otel_python_version }}
24+ otel_contrib_version : ${{ steps.get_versions.outputs.otel_contrib_version }}
25+ aws_sdk_ext_version : ${{ steps.get_versions.outputs.opentelemetry_sdk_extension_aws_version }}
26+ aws_xray_prop_version : ${{ steps.get_versions.outputs.opentelemetry_propagator_aws_xray_version }}
27+ breaking_changes_info : ${{ steps.breaking_changes.outputs.breaking_changes_info }}
28+
29+ steps :
30+ - name : Checkout repository
31+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
32+ with :
33+ fetch-depth : 0
34+ token : ${{ secrets.GITHUB_TOKEN }}
35+
36+ - name : Set up Python
37+ uses : actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
38+ with :
39+ python-version : ' 3.x'
40+
41+ - name : Install build tools
42+ run : |
43+ python -m pip install --upgrade pip
44+ pip install toml requests packaging
45+
46+ - name : Get latest upstream versions
47+ id : get_versions
48+ run : python scripts/get_upstream_versions.py
49+
50+ - name : Check for breaking changes
51+ id : breaking_changes
52+ env :
53+ OTEL_PYTHON_VERSION : ${{ steps.get_versions.outputs.otel_python_version }}
54+ OTEL_CONTRIB_VERSION : ${{ steps.get_versions.outputs.otel_contrib_version }}
55+ run : python scripts/find_breaking_changes.py
56+
57+ - name : Setup Git
58+ run : |
59+ git config user.name "github-actions"
60+ git config user.email "github-actions@github.com"
61+
62+ - name : Check out dependency update branch
63+ run : |
64+ if git ls-remote --exit-code --heads origin "$BRANCH_NAME"; then
65+ echo "Branch $BRANCH_NAME already exists, checking out..."
66+ git checkout "$BRANCH_NAME"
67+ else
68+ echo "Branch $BRANCH_NAME does not exist, creating new branch..."
69+ git checkout -b "$BRANCH_NAME"
70+ fi
71+
72+ - name : Update dependencies
73+ env :
74+ OTEL_PYTHON_VERSION : ${{ steps.get_versions.outputs.otel_python_version }}
75+ OTEL_CONTRIB_VERSION : ${{ steps.get_versions.outputs.otel_contrib_version }}
76+ OPENTELEMETRY_SDK_EXTENSION_AWS_VERSION : ${{ steps.get_versions.outputs.opentelemetry_sdk_extension_aws_version }}
77+ OPENTELEMETRY_PROPAGATOR_AWS_XRAY_VERSION : ${{ steps.get_versions.outputs.opentelemetry_propagator_aws_xray_version }}
78+ run : python scripts/update_dependencies.py
79+
80+ - name : Check for changes and commit
81+ id : check_changes
82+ run : |
83+ if git diff --quiet; then
84+ echo "No dependency updates needed"
85+ echo "has_changes=false" >> $GITHUB_OUTPUT
86+ else
87+ echo "Dependencies were updated"
88+ echo "has_changes=true" >> $GITHUB_OUTPUT
89+
90+ git add .
91+ git commit -m "chore: update OpenTelemetry dependencies to ${{ steps.get_versions.outputs.otel_python_version }}/${{ steps.get_versions.outputs.otel_contrib_version }}"
92+ git push origin "$BRANCH_NAME"
93+ fi
94+
95+ build-and-test :
96+ needs : update-dependencies
97+ if : needs.update-dependencies.outputs.has_changes == 'true'
98+ uses : ./.github/workflows/main-build.yml
99+ secrets : inherit
100+ permissions :
101+ id-token : write
102+ contents : read
103+ with :
104+ ref : nightly-dependency-updates
105+
106+ create-pr :
107+ needs : [update-dependencies, build-and-test]
108+ if : always() && needs.update-dependencies.outputs.has_changes == 'true'
109+ runs-on : ubuntu-latest
110+ steps :
111+ - name : Checkout repository
112+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
113+ with :
114+ token : ${{ secrets.GITHUB_TOKEN }}
115+
116+ - name : Create or update PR
117+ run : |
118+ BUILD_STATUS="${{ needs.build-and-test.result }}"
119+ BUILD_EMOJI="${{ needs.build-and-test.result == 'success' && '✅' || '❌' }}"
120+ BUILD_LINK="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
121+
122+ PR_BODY="Automated update of OpenTelemetry dependencies.
123+
124+ **Build Status:** ${BUILD_EMOJI} [${BUILD_STATUS}](${BUILD_LINK})
125+
126+ **Updated versions:**
127+ - [OpenTelemetry Python](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v${{ needs.update-dependencies.outputs.otel_python_version }}): ${{ needs.update-dependencies.outputs.otel_python_version }}
128+ - [OpenTelemetry Contrib](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v${{ needs.update-dependencies.outputs.otel_contrib_version }}): ${{ needs.update-dependencies.outputs.otel_contrib_version }}
129+ - [opentelemetry-sdk-extension-aws](https://pypi.org/project/opentelemetry-sdk-extension-aws/${{ needs.update-dependencies.outputs.aws_sdk_ext_version }}/): ${{ needs.update-dependencies.outputs.aws_sdk_ext_version }}
130+ - [opentelemetry-propagator-aws-xray](https://pypi.org/project/opentelemetry-propagator-aws-xray/${{ needs.update-dependencies.outputs.aws_xray_prop_version }}/): ${{ needs.update-dependencies.outputs.aws_xray_prop_version }}
131+
132+ **Upstream releases with breaking changes:**
133+ Note: the mechanism to detect upstream breaking changes is not perfect. Be sure to check all new releases and understand if any additional changes need to be addressed.
134+
135+ ${{ needs.update-dependencies.outputs.breaking_changes_info }}"
136+
137+ if gh pr view "$BRANCH_NAME" --json state --jq '.state' 2>/dev/null | grep -q "OPEN"; then
138+ echo "Open PR already exists, updating description..."
139+ gh pr edit "$BRANCH_NAME" --body "$PR_BODY"
140+ else
141+ echo "Creating new PR..."
142+ gh pr create \
143+ --title "Nightly dependency update: OpenTelemetry ${{ needs.update-dependencies.outputs.otel_python_version }}/${{ needs.update-dependencies.outputs.otel_contrib_version }}" \
144+ --body "$PR_BODY" \
145+ --base main \
146+ --head "$BRANCH_NAME"
147+ fi
148+ env :
149+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
150+
151+ publish-nightly-build-status :
152+ name : " Publish Nightly Build Status"
153+ needs : [ update-dependencies, build-and-test, create-pr ]
154+ runs-on : ubuntu-latest
155+ if : always()
156+ steps :
157+ - name : Configure AWS Credentials for emitting metrics
158+ uses : aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 # 5.0.0
159+ with :
160+ role-to-assume : ${{ secrets.MONITORING_ROLE_ARN }}
161+ aws-region : ${{ env.AWS_DEFAULT_REGION }}
162+
163+ - name : Publish nightly build status
164+ run : |
165+ if [[ "${{ needs.build-and-test.result }}" == "skipped" ]]; then
166+ echo "Build was skipped (no changes)"
167+ value="0.0"
168+ else
169+ value="${{ (needs.build-and-test.result == 'success' && needs.create-pr.result == 'success') && '0.0' || '1.0'}}"
170+ fi
171+
172+ aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
173+ --metric-name Failure \
174+ --dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=nightly_build \
175+ --value $value
0 commit comments