Skip to content

Conversation

@nikolai-laevskii
Copy link
Contributor

Adds shorthands for getting information about platform action is running on:

import { platform } from '@actions/core'

/* same as os.platform() */
platform.platform // 'win32' | 'darwin' | 'linux' | 'freebsd' | 'openbsd' | 'android' | 'cygwin' | 'sunos'

/* same as os.arch() */
platform.arch // 'x64' | 'arm' | 'arm64' | 'ia32' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 'riscv64' | 's390' | 's390x'

/* common shorthands for platform-specific logic */
platform.isWindows // true
platform.isMacOS // false
platform.isLinux // false

/* run platform-specific script to get more details about the exact platform, works on Windows, MacOS and Linux */
const {
  name, // Microsoft Windows 11 Enterprise
  version, // 10.0.22621
} = await platform.getDetails()

@nikolai-laevskii nikolai-laevskii requested a review from a team as a code owner October 9, 2023 03:54
@nikolai-laevskii nikolai-laevskii changed the title Add platform info utilities Add platform info utilities to @actions/core Oct 9, 2023
@dhensby
Copy link

dhensby commented Oct 8, 2024

I just want to say that I really appreciate this bit of functionality - thanks @nikolai-laevskii - it's allowed me to remove some custom code from my own action 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants