Skip to content

Commit aefcbbb

Browse files
committed
refactor workflow order
1 parent ede0ddb commit aefcbbb

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

.github/workflows/nightly-build.yml

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ env:
1818
BRANCH_NAME: nightly-dependency-updates
1919

2020
jobs:
21-
update-and-create-pr:
21+
update-dependencies:
2222
runs-on: ubuntu-latest
2323
outputs:
2424
has_changes: ${{ steps.check_changes.outputs.has_changes }}
25+
breaking_changes_info: ${{ steps.breaking_changes.outputs.breaking_changes_info }}
2526

2627
steps:
2728
- name: Checkout repository
@@ -74,14 +75,38 @@ jobs:
7475
git commit -m "chore: update OpenTelemetry dependencies to latest versions"
7576
git push origin "$BRANCH_NAME"
7677
fi
78+
79+
build-and-test:
80+
needs: update-dependencies
81+
if: needs.update-dependencies.outputs.has_changes == 'true'
82+
uses: ./.github/workflows/main-build.yml
83+
secrets: inherit
84+
with:
85+
caller-workflow-name: nightly-build
86+
ref: nightly-dependency-updates
87+
88+
create-pr:
89+
needs: [update-dependencies, build-and-test]
90+
if: always() && needs.update-dependencies.outputs.has_changes == 'true'
91+
runs-on: ubuntu-latest
92+
steps:
93+
- name: Checkout repository
94+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
95+
with:
96+
token: ${{ secrets.GITHUB_TOKEN }}
7797

7898
- name: Create or update PR
79-
if: steps.check_changes.outputs.has_changes == 'true'
8099
run: |
100+
BUILD_STATUS="${{ needs.build-and-test.result }}"
101+
BUILD_EMOJI="${{ needs.build-and-test.result == 'success' && '✅' || '❌' }}"
102+
BUILD_LINK="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
103+
81104
PR_BODY="Automated update of OpenTelemetry dependencies to their latest available versions.
82105
106+
**Build Status:** ${BUILD_EMOJI} [${BUILD_STATUS}](${BUILD_LINK})
107+
83108
**Upstream releases with breaking changes:**
84-
${{ steps.breaking_changes.outputs.breaking_changes_info }}"
109+
${{ needs.update-dependencies.outputs.breaking_changes_info }}"
85110
86111
if gh pr view "$BRANCH_NAME" --json state --jq '.state' 2>/dev/null | grep -q "OPEN"; then
87112
echo "Open PR already exists, updating description..."
@@ -97,18 +122,9 @@ jobs:
97122
env:
98123
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99124

100-
build-and-test:
101-
needs: update-and-create-pr
102-
if: needs.update-and-create-pr.outputs.has_changes == 'true'
103-
uses: ./.github/workflows/main-build.yml
104-
secrets: inherit
105-
with:
106-
caller-workflow-name: nightly-build
107-
ref: nightly-dependency-updates
108-
109125
publish-nightly-build-status:
110126
name: "Publish Nightly Build Status"
111-
needs: [update-and-create-pr, build-and-test]
127+
needs: [update-dependencies, build-and-test, create-pr]
112128
runs-on: ubuntu-latest
113129
if: always()
114130
steps:
@@ -121,11 +137,13 @@ jobs:
121137
- name: Publish nightly build status
122138
run: |
123139
if [[ "${{ needs.build-and-test.result }}" == "skipped" ]]; then
124-
echo "Build was skipped (no changes), not publishing metric"
140+
echo "Build was skipped (no changes)"
141+
value="0.0"
125142
else
126-
value="${{ needs.build-and-test.result == 'success' && '0.0' || '1.0'}}"
127-
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
128-
--metric-name Failure \
129-
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=nightly_build \
130-
--value $value
143+
value="${{ (needs.build-and-test.result == 'success' && needs.create-pr.result == 'success') && '0.0' || '1.0'}}"
131144
fi
145+
146+
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
147+
--metric-name Failure \
148+
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=nightly_build \
149+
--value $value

0 commit comments

Comments
 (0)