Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/actions/get-aws-instance-type/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ runs:
using: 'composite'
steps:
- name: Get AWS instance type
if: ${{ runner.os != 'Windows' }}
shell: bash
run: |
# Get token and instance type from EC2 metadata service
Expand All @@ -16,10 +17,18 @@ runs:
-H "X-aws-ec2-metadata-token: $TOKEN" \
"http://169.254.169.254/latest/meta-data/instance-type" 2>/dev/null || true)

# if not EC2, set to self-hosted
if [ -z "$AWS_INSTANCE_TYPE" ]; then
AWS_INSTANCE_TYPE="self-hosted"
fi

echo "AWS_INSTANCE_TYPE=$AWS_INSTANCE_TYPE" >> $GITHUB_ENV
echo $AWS_INSTANCE_TYPE

- name: Get AWS instance type (Windows)
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
try {
$Token = Invoke-RestMethod -Uri "http://169.254.169.254/latest/api/token" -Method PUT -Headers @{ "X-aws-ec2-metadata-token-ttl-seconds" = "10" }
$InstanceType = Invoke-RestMethod -Uri "http://169.254.169.254/latest/meta-data/instance-type" -Headers @{ "X-aws-ec2-metadata-token" = $Token }
# https://github.com/actions/runner-images/issues/5251#issuecomment-1071030822
echo "AWS_INSTANCE_TYPE=$InstanceType" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output $InstanceType
} catch { Write-Warning -Message "Error returned! $_" }

4 changes: 4 additions & 0 deletions .github/workflows/build-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
# Download sub-submodules for certain submodules. We don't recurse above in Checkout to improve build performance. See: https://github.com/actions/checkout/issues/1779
git submodule update --init --recursive --depth 1 thirdparty/mrbind

- name: Get AWS instance type
uses: ./.github/actions/get-aws-instance-type

- name: Collect runner's system stats
if: ${{ inputs.internal_build }}
continue-on-error: true
Expand All @@ -68,6 +71,7 @@ jobs:
cxx_compiler: ${{ matrix.os }} # os name will be transformed to MSVC name (e.g. windows-2022 -> msvc-2022)
build_config: ${{ matrix.config }}
build_system: ${{ matrix.build_system }}
aws_instance_type: ${{ env.AWS_INSTANCE_TYPE }}

- name: Clean Vcpkg Directory
if: ${{ matrix.os == 'windows-2022' }}
Expand Down
Loading