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:
- Host: GitHub
- URL: https://github.com/andry81-devops/gh-action--check-os-version
- Owner: andry81-devops
- License: mit
- Created: 2022-08-29T15:36:58.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-02-03T01:08:51.000Z (4 months ago)
- Last Synced: 2025-03-06T06:20:09.924Z (3 months ago)
- Topics: action, comosite-action, github-action, version
- Homepage: https://github.com/andry81-devops/github-action-extensions
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.txt
- Funding: .github/FUNDING.yml
- License: license.txt
Awesome Lists containing this project
README
---
Userlog
• Changelog
• Known issues
•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)