Skip to content

Commit ed8294e

Browse files
committed
fix branching logic and add metric
1 parent 8cf6aac commit ed8294e

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

.github/workflows/nightly-build.yml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ on:
55
- cron: "21 3 * * *"
66
workflow_dispatch:
77

8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
id-token: write
12+
813
env:
14+
AWS_DEFAULT_REGION: us-east-1
915
BRANCH_NAME: nightly-dependency-updates
1016

1117
jobs:
@@ -21,19 +27,20 @@ jobs:
2127
fetch-depth: 0
2228
token: ${{ secrets.GITHUB_TOKEN }}
2329

24-
- name: Check if nightly branch already exists
25-
run: |
26-
if git ls-remote --exit-code --heads origin "$BRANCH_NAME"; then
27-
echo "Branch $BRANCH_NAME already exists. Skipping run to avoid conflicts."
28-
echo "Please merge or close the existing PR before the next nightly run."
29-
exit 1
30-
fi
31-
32-
- name: Configure git and create branch
30+
- name: Configure git
3331
run: |
3432
git config --local user.email "[email protected]"
3533
git config --local user.name "GitHub Action"
36-
git checkout -b "$BRANCH_NAME"
34+
35+
- name: Check out dependency update branch
36+
run: |
37+
if git ls-remote --exit-code --heads origin "$BRANCH_NAME"; then
38+
echo "Branch $BRANCH_NAME already exists, checking out..."
39+
git checkout "$BRANCH_NAME"
40+
else
41+
echo "Branch $BRANCH_NAME does not exist, creating new branch..."
42+
git checkout -b "$BRANCH_NAME"
43+
fi
3744
3845
- name: Set up Python
3946
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c #v6.0.0
@@ -66,7 +73,8 @@ jobs:
6673
git add dependencyManagement/build.gradle.kts
6774
git commit -m "chore: update OpenTelemetry dependencies to latest versions"
6875
git push origin "$BRANCH_NAME"
69-
76+
fi
77+
7078
- name: Create or update PR
7179
if: steps.check_changes.outputs.has_changes == 'true'
7280
run: |
@@ -89,3 +97,24 @@ jobs:
8997
fi
9098
env:
9199
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
101+
publish-nightly-build-status:
102+
name: "Publish Nightly Build Status"
103+
needs: [update-and-create-pr]
104+
runs-on: ubuntu-latest
105+
if: always()
106+
steps:
107+
- name: Configure AWS Credentials for emitting metrics
108+
uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 #v5.0.0
109+
with:
110+
role-to-assume: ${{ secrets.MONITORING_ROLE_ARN }}
111+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
112+
113+
- name: Publish nightly build status
114+
run: |
115+
# For now, just publish success since we don't have build validation yet
116+
value="${{ needs.update-and-create-pr.result == 'success' && '0.0' || '1.0'}}"
117+
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
118+
--metric-name Failure \
119+
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=nightly_build \
120+
--value $value

0 commit comments

Comments
 (0)