An open API service indexing awesome lists of open source software.

https://github.com/andry81-devops/gh-action--check-os-version

GitHub composite action to check and read OS version details into variables. • :page_with_curl: https://github.com/andry81-stats/gh-action--check-os-version--gh-stats :page_with_curl:
https://github.com/andry81-devops/gh-action--check-os-version

action comosite-action github-action version

Last synced: about 2 months ago
JSON representation

GitHub composite action to check and read OS version details into variables. • :page_with_curl: https://github.com/andry81-stats/gh-action--check-os-version--gh-stats :page_with_curl:

Awesome Lists containing this project

README

        



GitHub repo size in bytes


lines of code by tokei.rs



GitHub views|any|total
GitHub views|any|14d


GitHub views|unique per day|total
GitHub views|unique per day|14d



GitHub clones|any|total
GitHub clones|any|14d


GitHub clones|unique per day|total
GitHub clones|unique per day|14d



GitHub commits since latest version


latest release name


GitHub all releases


donate

---


Userlog
Changelog
Known issues
copyright and license Copyright and License

GitHub composite action to check and read OS version details into variables.

> [!WARNING]
> Currently implemented ONLY a Linux version details check.

Tutorial to use with: https://github.com/andry81-devops/github-action-extensions

All tutorials: https://github.com/andry81/index#tutorials

##

# gh-action--check-os-version@master

**Features**:

* Checks set of ways to read OS version details using input parameters:

* ```yml
gh-var-tags: runner-os
```

> ${{ runner.os }}

* ```yml
linux-files: /etc/os-release
```

> cat '/etc/os-release'

* ```yml
linux-commands: |
echo "$ImageOS: $ImageVersion"
lsb_release -a
hostnamectl
uname -r
```

> echo "$ImageOS: $ImageVersion"

> lsb_release -a

> hostnamectl

> uname -r

# USAGE

## Example snippet:

```yml
steps:
- name: check os version
id: check-os-version
uses: andry81-devops/gh-action--check-os-version@master
with:
gh-var-tags: runner-os
linux-files: /etc/os-release
linux-commands: |
echo "$ImageOS: $ImageVersion"
uname -r
lsb_release -a
hostnamectl

- name: read and decode return values
shell: bash
env:
check_os_version: ${{ steps.check-os-version.outputs.json-return-values }}
run: |
check_os_version="${check_os_version//$'\t'/\\t}"
check_os_version="${check_os_version//$'\n'/\\n}"
check_os_version="${check_os_version//$'\r'/\\r}"
echo "check_os_version=$check_os_version" >> "$GITHUB_ENV"
echo "check_os_version=$check_os_version"
echo "JSON_RETURN_VALUES=$JSON_RETURN_VALUES"

- name: print return values
shell: bash
run: |
check_os_version="$(echo -n "$check_os_version" | tr -d [:cntrl:])"

jq <<< "$check_os_version"

for key in $(jq -r "keys|.[]" <<< "$check_os_version"); do
case "$key" in
gh-vars)
title_var="name"
value_var="value"
;;
linux-files)
title_var="file"
value_var="value"
;;
linux-commands)
title_var="line"
value_var="out"
;;
esac

for i in $(jq -r ".\"$key\"|keys|.[]" <<< "$check_os_version"); do
# suppress not zero exit code
IFS=$'\n' read -r -d '' title value <<< $(jq -r ".\"$key\"[$i].$title_var,.\"$key\"[$i].$value_var" <<< "$check_os_version") || (( 1 ))
value="${value//\\t/$'\t'}"
value="${value//\\n/$'\n'}"
value="${value//\\r/$'\r'}"
value="${value//\\\"/\"}"
value="${value//\\\\/\\}"
echo ">$title:"$'\n'"$value"$'\n---'
done
done
```

---

> [!NOTE]
> See REUSE section for details if you have multiple repositories and want to store all GitHub workflow scripts (`.github/workflows/*.yml`) in a single repository.

## Known Issues

https://github.com/andry81-devops/gh-known-issues#known-issues

## Last known issues updates

https://github.com/andry81-devops/gh-known-issues#last-known-issues-updates

## Copyright and License

Code and documentation copyright 2022 Andrey Dibrov. Code released under [MIT License](https://github.com/andry81-devops/gh-action--check-os-version/tree/HEAD/license.txt)