Skip to content

Commit 816a142

Browse files
committed
explicitly sort workflows by time
1 parent 1f284bd commit 816a142

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

.github/workflows/release-build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ jobs:
2727
- uses: actions/checkout@v5
2828

2929
- name: Check main build status
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3032
run: |
3133
WORKFLOW_ID=$(gh api repos/${{ github.repository }}/actions/workflows --jq '.workflows[] | select(.name=="Java Agent Main Build") | .id')
32-
LATEST_RUN=$(gh api repos/${{ github.repository }}/actions/workflows/$WORKFLOW_ID/runs --jq '.workflow_runs[] | select(.head_branch=="${{ github.ref_name }}") | {conclusion, status}' | head -1)
34+
LATEST_RUN=$(gh api repos/${{ github.repository }}/actions/workflows/$WORKFLOW_ID/runs --jq '[.workflow_runs[] | select(.head_branch=="${{ github.ref_name }}")] | sort_by(.created_at) | reverse | .[0] | {conclusion, status}')
3335
STATUS=$(echo "$LATEST_RUN" | jq -r '.status')
3436
CONCLUSION=$(echo "$LATEST_RUN" | jq -r '.conclusion')
3537
@@ -41,8 +43,6 @@ jobs:
4143
exit 1
4244
fi
4345
echo "Main build succeeded, proceeding with release"
44-
env:
45-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4646
- uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
4747
with:
4848
java-version-file: .java-version

0 commit comments

Comments
 (0)