Skip to content

test: concurrent workflows #7

test: concurrent workflows

test: concurrent workflows #7

Workflow file for this run

name: Release Lambda
on:
push:
tags:
- '*'
jobs:
check-runner:
name: Check Runner Availability
runs-on: ubuntu-latest
outputs:
runner-label: ${{ steps.set-runner.outputs.runner-label }}
steps:
- name: Set runner
id: set-runner
run: |
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)
if [ $? -ne 0 ]; then
echo "Error: Failed to fetch runners from GitHub API" >&2
exit 1
fi
runners_count=$(echo "$runners" | jq '.runners | length')
if [ "$runners_count" -eq 0 ]; then
echo "No runners available or failed to retrieve runners." >&2
echo "runner-label=ubuntu-latest" >> $GITHUB_OUTPUT
exit 0
fi
available=$(echo "$runners" | jq '.runners[] | select(.status == "online" and .busy == false and .labels[] .name == "self-hosted")')
if [ $? -ne 0 ]; then
echo "Error: Failed to parse JSON response" >&2
exit 1
fi
if [ -n "$available" ]; then
echo "runner-label=lambda-linux-runner" >> $GITHUB_OUTPUT
else
echo "runner-label=ubuntu-latest" >> $GITHUB_OUTPUT
fi
build:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
needs: check-runner
runs-on: ${{ needs.check-runner.outputs.runner-label }}
name: Build and Release Lambda
permissions:
contents: write
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
steps:
- name: Checkout Repository
uses: actions/checkout@v4.1.1
- name: Set-Up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
architecture: x64
cache: 'gradle'
- name: Read Gradle Properties
uses: BrycensRanch/read-properties-action@v1.0.4
id: all
with:
file: gradle.properties
all: true
- name: Build Lambda
run: ./gradlew build
- name: Create Release
uses: softprops/action-gh-release@v2.0.8
with:
name: Lambda ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
generate_release_notes: true
append_body: true
make_latest: "true"
files: |
fabric/build/libs/lambda-fabric-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}.jar
forge/build/libs/lambda-forge-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}.jar