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

feature - V1.1 - New features #6

Merged
merged 27 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
62 changes: 62 additions & 0 deletions .github/workflows/ci-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Continuous Integration - Docker

on:
pull_request:
branches:
- main
push:
branches:
- main
- feature/**

permissions:
contents: read

jobs:
test-docker:
name: Docker Tests
runs-on: ubuntu-latest

services:
registry:
image: registry:2
ports:
- 5001:5000

env:
TEST_TAG: localhost:5001/actions/yq-yaml-parser-action:latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Setup Docker BuildX
id: setup-buildx
uses: docker/setup-buildx-action@v3
with:
install: true
driver-opts: network=host

- name: Build the Container
id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.TEST_TAG }}

- name: Run the Container
id: run
env:
INPUT_YAML_FILE_PATH: ./yq-test-action.yml
run: |
docker run \
--workdir /github/workspace \
--volume "${{ github.workspace }}":/github/workspace \
--env GITHUB_OUTPUT="/github/workspace/github_output.txt" \
--env INPUT_YAML_FILE_PATH="${{ env.INPUT_YAML_FILE_PATH }}" \
--rm ${{ env.TEST_TAG }}
echo ""
echo "Run Output:"
cat ${{ github.workspace }}/github_output.txt
100 changes: 100 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Continuous Integration - Test Action

on:
pull_request:
branches:
- main
push:
branches:
- main
- feature/**

permissions:
contents: read

jobs:
test-action:
name: Action Test Output
runs-on: ubuntu-latest

outputs:
comment-line: ${{ steps.action.outputs.test-action_comment-line }}
to-dont-read: ${{ steps.action.outputs.test-action_to-dont-read }}
multiline: ${{ steps.action.outputs.test-action_multiline }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Action
id: action
uses: ./
with:
file-path: ./yq-test-action.yml
filtering-keys: |
test-action_comment-line
test-action_to-rename
test-action_multiline
renaming-outputs: |
test-action_to-rename=test-action_renamed

test-action-output-comment-line:
name: Action Test Output - Comment Line
needs: test-action
runs-on: ubuntu-latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Output Comment Line
id: test-output-comment-line
run: |
test_name="Test Output Comment Line"
expected="./app ="
.github/scripts/test-action-output.sh \
"$test_name" \
"$expected" \
"${{ needs.test-action.outputs.comment-line }}"

test-action-output-dont-read:
name: Action Test Output - Don't Read
needs: test-action
runs-on: ubuntu-latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Output Don't Read
id: test-output-dont-read
run: |
test_name="Test Output Don't Read"
expected=''
.github/scripts/test-action-output.sh \
"$test_name" \
"$expected" \
"${{ needs.test-action.outputs.to-dont-read }}"

test-action-output-multiline:
name: Action Test Output - Multiline
needs: test-action
runs-on: ubuntu-latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Output Multiline
id: test-output-multiline
run: |
test_name="Test Output Multiline"
expected="### Heading\n\n* Bullet C:\\\n* Driver D:\\\\\n* Points"
expected=$(printf '%s' "${expected}" | sed -e 's/\\n/\n/g')
.github/scripts/test-action-output.sh \
"$test_name" \
"$expected" \
"${{ needs.test-action.outputs.multiline }}"
112 changes: 0 additions & 112 deletions .github/workflows/ci.yml

This file was deleted.

23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# yq YAML parser action
# YAML parser action

[![GitHub Super-Linter](https://github.com/actions-betaon/yq-yaml-parser/actions/workflows/linter.yml/badge.svg)](https://github.com/super-linter/super-linter)
![CI](https://github.com/actions-betaon/yq-yaml-parser/actions/workflows/ci.yml/badge.svg)
![CI Docker](https://github.com/actions-betaon/yq-yaml-parser/actions/workflows/ci-docker.yml/badge.svg)
![CI Test](https://github.com/actions-betaon/yq-yaml-parser/actions/workflows/ci-test.yml/badge.svg)

This action reads values from a YAML file setting as action outputs.

To learn how this action was built, see [Creating a Docker container action](https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action).

## Usage

Here's an example of how to use this action in a workflow file:
Expand All @@ -21,6 +20,14 @@ on:
description: "Path to the yaml file to parser"
required: true
type: string
yaml-filtering-keys:
description: "Read using specific keys"
required: false
type: string
yaml-renaming-outputs:
description: "Used to rename the default output name"
required: false
type: string

jobs:
yq-yaml-parser:
Expand All @@ -33,13 +40,17 @@ jobs:
uses: actions-betaon/[email protected]
with:
file-path: '${{ inputs.yaml-file-path }}'
filtering-keys: '${{ inputs.yaml-filtering-keys }}'
renaming-outputs: '${{ inputs.yaml-renaming-outputs }}'
```

## Inputs

| Input | Description | Default |
| Input | Description | Required |
| ----------- | ------------------------------- | ----------- |
| `file-path` | Path to the YAML file to parse as output | |
| `file-path` | Path to the YAML file to parse as output | true |
| `filtering-keys` | The YAML key names list to filter as read | false |
| `renaming-outputs` | The YAML rename "keyname=output" output list | false |

## Outputs

Expand Down
21 changes: 19 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: yq-yaml-parser
name: yq yaml parser
description: Convert a yaml to GitHub Actions outputs
author: BetaOn Actions

Expand All @@ -8,11 +8,28 @@ branding:

inputs:
file-path:
description: "Path to the yaml file to read"
description: Path to the yaml file to read
required: true
filtering-keys:
description: |
Read using specific keys
filtering-keys: |
key1_nested
key2_nested_0
If not provided, all keys will be read
required: false
renaming-outputs:
description: |
Can be used to rename the default output name
renaming-outputs: |
key1_nested=my_output
key2_nested_0=my_output_2
required: false

runs:
using: docker
image: Dockerfile
env:
INPUT_YAML_FILE_PATH: "${{ inputs.file-path }}"
INPUT_YAML_FILTERING_KEYS: "${{ inputs.filtering-keys }}"
INPUT_YAML_RENAMING_OUTPUTS: "${{ inputs.renaming-outputs }}"
Loading