Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow yaml for config and build in info action #46

Merged
merged 5 commits into from
Sep 25, 2021
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
29 changes: 29 additions & 0 deletions .github/workflows/helpers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,32 @@ jobs:

- name: Verify installation
run: which vcn

info:
runs-on: ubuntu-latest
name: info
strategy:
fail-fast: False
matrix:
file:
- "build"
- "config"
type:
- "json"
- "yaml"

steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Test
uses: ./helpers/info
id: info
with:
path: "test_files/${{ matrix.file }}_${{ matrix.type }}"

- name: Validate result
run: |
if [[ '${{ steps.info.outputs.architectures }}' != '["aarch64","armv7","armhf","amd64","i386"]' ]]; then
exit 1
fi
23 changes: 16 additions & 7 deletions helpers/info/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ runs:
- shell: bash
id: architectures
run: |
if [[ -f "${{ inputs.path }}/build.json" ]]; then
archs=$(jq -r '.build_from | keys | [ .[] | tostring ] | @json' "${{ inputs.path }}/build.json")
elif [[ -f "${{ inputs.path }}/config.json" ]]; then
archs=$(jq -r '.arch | [ .[] | tostring ] | @json' "${{ inputs.path }}/config.json")
else
archs=[]
fi
archs=[]
mkdir -p "${{ github.action_path }}/bin"
wget -q -O "${{ github.action_path }}/bin/yq" https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
chmod a+x "${{ github.action_path }}/bin/yq"
echo "${{ github.action_path }}/bin" >> "$GITHUB_PATH"
for file_type in json yml yaml; do
if [[ -f "${{ inputs.path }}/build.${file_type}" ]]; then
archs=$(yq e -N -M '.build_from | keys' -o=json -I=0 "${{ inputs.path }}/build.${file_type}")
break
elif [[ -f "${{ inputs.path }}/config.${file_type}" ]]; then
archs=$(yq e -N -M '.arch' -o=json -I=0 "${{ inputs.path }}/config.${file_type}")
break
fi
done
echo "::set-output name=architectures::$archs"
9 changes: 9 additions & 0 deletions test_files/build_json/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"build_from": {
"aarch64": "ghcr.io/home-assistant/aarch64-base:3.13",
"armv7": "ghcr.io/home-assistant/armv7-base:3.13",
"armhf": "ghcr.io/home-assistant/armhf-base:3.13",
"amd64": "ghcr.io/home-assistant/amd64-base:3.13",
"i386": "ghcr.io/home-assistant/i386-base:3.13"
}
}
7 changes: 7 additions & 0 deletions test_files/build_yaml/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
build_from:
aarch64: ghcr.io/home-assistant/aarch64-base:3.13
armv7: ghcr.io/home-assistant/armv7-base:3.13
armhf: ghcr.io/home-assistant/armhf-base:3.13
amd64: ghcr.io/home-assistant/amd64-base:3.13
i386: ghcr.io/home-assistant/i386-base:3.13
3 changes: 3 additions & 0 deletions test_files/config_json/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"arch": ["aarch64","armv7","armhf","amd64","i386"]
}
7 changes: 7 additions & 0 deletions test_files/config_yaml/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
arch:
- aarch64
- armv7
- armhf
- amd64
- i386