Skip to content

Commit d2d7f16

Browse files
committed
test: concurrent workflows
1 parent 000fae4 commit d2d7f16

File tree

3 files changed

+54
-13
lines changed

3 files changed

+54
-13
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ on:
55
branches:
66
- '**'
77

8-
concurrency:
9-
group: ${{ github.workflow }}-${{ github.ref }}
10-
118
jobs:
129
check-runner:
1310
name: Check Runner Availability
@@ -45,6 +42,10 @@ jobs:
4542
echo "runner-label=ubuntu-latest" >> $GITHUB_OUTPUT
4643
fi
4744
build:
45+
concurrency:
46+
group: ${{ github.workflow }}-${{ needs.check-runner.outputs.runner-label }}
47+
cancel-in-progress: true
48+
4849
needs: check-runner
4950
runs-on: ${{ needs.check-runner.outputs.runner-label }}
5051

@@ -111,7 +112,7 @@ jobs:
111112
112113
#### [API (Developer Dependency)](https://r2-bucket.edouard127.christmas/${{ env.DATE }}-${{ env.COMMIT_HASH }}/lambda-api-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-${{ env.COMMIT_HASH }}.jar)
113114
114-
- **Runner:** \`${{ needs.check-runner.outputs.runner-label }}\`
115+
**Runner:** \`${{ needs.check-runner.outputs.runner-label }}\`
115116
EOF
116117
117118
- name: Failover Upload

.github/workflows/publish-maven.yml

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,53 @@ on:
55
tags:
66
- '*'
77

8-
concurrency:
9-
group: ${{ github.workflow }}-${{ github.ref }}
10-
118
jobs:
12-
maven:
13-
name: Publish artifacts to maven
9+
check-runner:
10+
name: Check Runner Availability
1411
runs-on: ubuntu-latest
12+
13+
outputs:
14+
runner-label: ${{ steps.set-runner.outputs.runner-label }}
15+
16+
steps:
17+
- name: Set runner
18+
id: set-runner
19+
run: |
20+
runners=$(curl -v -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.REPO_ACCESS_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/runners" --http1.1)
21+
if [ $? -ne 0 ]; then
22+
echo "Error: Failed to fetch runners from GitHub API" >&2
23+
exit 1
24+
fi
25+
26+
runners_count=$(echo "$runners" | jq '.runners | length')
27+
if [ "$runners_count" -eq 0 ]; then
28+
echo "No runners available or failed to retrieve runners." >&2
29+
echo "runner-label=ubuntu-latest" >> $GITHUB_OUTPUT
30+
exit 0
31+
fi
32+
33+
available=$(echo "$runners" | jq '.runners[] | select(.status == "online" and .busy == false and .labels[] .name == "self-hosted")')
34+
if [ $? -ne 0 ]; then
35+
echo "Error: Failed to parse JSON response" >&2
36+
exit 1
37+
fi
38+
39+
if [ -n "$available" ]; then
40+
echo "runner-label=lambda-linux-runner" >> $GITHUB_OUTPUT
41+
else
42+
echo "runner-label=ubuntu-latest" >> $GITHUB_OUTPUT
43+
fi
44+
45+
publish:
46+
concurrency:
47+
group: ${{ github.workflow }}-${{ needs.check-runner.outputs.runner-label }}
48+
cancel-in-progress: true
49+
50+
needs: check-runner
51+
runs-on: ${{ needs.check-runner.outputs.runner-label }}
52+
53+
name: Publish artifacts to maven
54+
1555
steps:
1656
- name: Checkout Repository
1757
uses: actions/checkout@v4

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ on:
55
tags:
66
- '*'
77

8-
concurrency:
9-
group: ${{ github.workflow }}-${{ github.ref }}
10-
cancel-in-progress: true
11-
128
jobs:
139
check-runner:
1410
name: Check Runner Availability
@@ -46,6 +42,10 @@ jobs:
4642
echo "runner-label=ubuntu-latest" >> $GITHUB_OUTPUT
4743
fi
4844
build:
45+
concurrency:
46+
group: ${{ github.workflow }}-${{ needs.check-runner.outputs.runner-label }}
47+
cancel-in-progress: true
48+
4949
needs: check-runner
5050
runs-on: ${{ needs.check-runner.outputs.runner-label }}
5151

0 commit comments

Comments
 (0)