Added many, many more actions.
This commit is contained in:
44
yq/yq-convert/action.yaml
Normal file
44
yq/yq-convert/action.yaml
Normal file
@@ -0,0 +1,44 @@
|
||||
name: yq-convert
|
||||
description: "Change the language format of a file."
|
||||
inputs:
|
||||
from:
|
||||
#yaml, json, xml
|
||||
description: "Format to convert from..."
|
||||
required: true
|
||||
to:
|
||||
#yaml, json, xml
|
||||
description: "Format to convert to..."
|
||||
required: true
|
||||
input:
|
||||
#yaml, json, xml
|
||||
description: "File or data to convert."
|
||||
required: true
|
||||
tmpDir:
|
||||
description: "Temporary directory. Default: _tmp"
|
||||
required: true
|
||||
default: _tmp
|
||||
outputs:
|
||||
result:
|
||||
description: "The converted file."
|
||||
value: ${{ steps.convert.outputs.console }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Make temporary file of input."
|
||||
id: mktmp
|
||||
uses: act/common/utils/mktemp@master
|
||||
with:
|
||||
input: ${{ inputs.input }}
|
||||
tmpDir: ${{ inputs.tmpDir }}
|
||||
- name: "Convert file."
|
||||
id: convert
|
||||
uses: act/common/yq/yq@master
|
||||
with:
|
||||
command: -p ${{ inputs.from }} -o ${{ inputs.to }} "${{ steps.mktmp.outputs.tmp }}"
|
||||
- name: "Take ownership of the artifacts."
|
||||
uses: act/common/utils/chown@master
|
||||
with:
|
||||
file: ${{ inputs.tmpDir }}
|
||||
- name: "Remove temporary files."
|
||||
run: rm -rf "${{ inputs.tmpDir }}"
|
||||
shell: bash
|
||||
35
yq/yq-expression/action.yaml
Normal file
35
yq/yq-expression/action.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
name: yq-expression
|
||||
description: "Change the language format of a file."
|
||||
inputs:
|
||||
input:
|
||||
description: "Yaml to run the expression on."
|
||||
required: true
|
||||
expression:
|
||||
description: "Expression to run."
|
||||
required: true
|
||||
default: "."
|
||||
tmpDir:
|
||||
description: "Temporary directory. Default: _tmp"
|
||||
required: true
|
||||
default: _tmp
|
||||
outputs:
|
||||
result:
|
||||
description: "The converted file."
|
||||
value: ${{ steps.expression.outputs.console }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Make temporary file of input."
|
||||
id: input
|
||||
uses: act/common/utils/mktemp@master
|
||||
with:
|
||||
input: ${{ inputs.input }}
|
||||
tmpDir: ${{ inputs.tmpDir }}
|
||||
- name: "Run expression."
|
||||
id: expression
|
||||
uses: act/common/yq/yq@master
|
||||
with:
|
||||
command: "'${{ inputs.expression }}' '${{ steps.input.outputs.tmp }}'"
|
||||
- name: "Remove temporary files."
|
||||
run: rm -rf "${{ inputs.tmpDir }}"
|
||||
shell: bash
|
||||
48
yq/yq-merge/action.yaml
Normal file
48
yq/yq-merge/action.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
name: yq-merge
|
||||
description: "Change the language format of a file."
|
||||
inputs:
|
||||
lhs:
|
||||
description: "Left-hand side of merge."
|
||||
required: true
|
||||
rhs:
|
||||
description: "Right-hand side of merge."
|
||||
required: true
|
||||
operator:
|
||||
description: "Merge operator. See: https://mikefarah.gitbook.io/yq/operators/multiply-merge"
|
||||
required: true
|
||||
default: "*+"
|
||||
element:
|
||||
description: "Element to merge."
|
||||
required: true
|
||||
default: "."
|
||||
tmpDir:
|
||||
description: "Temporary directory. Default: _tmp"
|
||||
required: true
|
||||
default: _tmp
|
||||
outputs:
|
||||
result:
|
||||
description: "The converted file."
|
||||
value: ${{ steps.merge.outputs.console }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Make temporary file of first input."
|
||||
id: lhs
|
||||
uses: act/common/utils/mktemp@master
|
||||
with:
|
||||
input: ${{ inputs.lhs }}
|
||||
tmpDir: ${{ inputs.tmpDir }}
|
||||
- name: "Make temporary file of second input."
|
||||
id: rhs
|
||||
uses: act/common/utils/mktemp@master
|
||||
with:
|
||||
input: ${{ inputs.rhs }}
|
||||
tmpDir: ${{ inputs.tmpDir }}
|
||||
- name: "Merge files."
|
||||
id: merge
|
||||
uses: act/common/yq/yq@master
|
||||
with:
|
||||
command: "'${{ inputs.element }} ${{ inputs.operator }} load(\"${{ steps.rhs.outputs.tmp }}\")' '${{ steps.lhs.outputs.tmp }}'"
|
||||
- name: "Remove temporary files."
|
||||
run: rm -rf "${{ inputs.tmpDir }}"
|
||||
shell: bash
|
||||
44
yq/yq-trim/action.yaml
Normal file
44
yq/yq-trim/action.yaml
Normal file
@@ -0,0 +1,44 @@
|
||||
name: yq-trim
|
||||
description: "Change the language format of a file."
|
||||
inputs:
|
||||
input:
|
||||
description: "Left-hand side of merge."
|
||||
required: true
|
||||
recursive:
|
||||
description: "Recursivevly trim the input. Default: true"
|
||||
required: true
|
||||
default: "true"
|
||||
tmpDir:
|
||||
description: "Temporary directory. Default: _tmp"
|
||||
required: true
|
||||
default: _tmp
|
||||
outputs:
|
||||
result:
|
||||
description: "The converted file."
|
||||
value: ${{ steps.trim.outputs.console }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Make temporary file of input."
|
||||
id: input
|
||||
uses: act/common/utils/mktemp@master
|
||||
with:
|
||||
input: ${{ inputs.input }}
|
||||
tmpDir: ${{ inputs.tmpDir }}
|
||||
- name: "Make temporary file of script."
|
||||
id: script
|
||||
uses: act/common/utils/mktemp@master
|
||||
with:
|
||||
input: ${{ github.action_path }}/trim.sh
|
||||
tmpDir: .
|
||||
- name: "Run script."
|
||||
id: trim
|
||||
uses: act/common/yq/yq@master
|
||||
with:
|
||||
program: bash
|
||||
command: ${{ steps.script.outputs.tmp }} ${{ steps.input.outputs.tmp }} ${{ inputs.recursive }}
|
||||
- name: "Remove temporary files."
|
||||
run: |
|
||||
rm "${{ steps.script.outputs.tmp }}"
|
||||
rm -rf "${{ inputs.tmpDir }}"
|
||||
shell: bash
|
||||
16
yq/yq-trim/trim.sh
Normal file
16
yq/yq-trim/trim.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
INPUT="$1"
|
||||
RECURSIVE="$2"
|
||||
|
||||
if [[ -f "$INPUT" ]]; then
|
||||
INPUT=$(cat "$INPUT")
|
||||
fi
|
||||
|
||||
OUTPUT=$(echo "$INPUT" | yq e 'del(.. | select(length == 0))')
|
||||
if [[ "$RECURSIVE" == "true" ]]; then
|
||||
while [ "$(echo "$OUTPUT" | yq e 'map (.. | select (length == 0)) | any')" = "true" ]; do
|
||||
OUTPUT=$(echo "$OUTPUT" | yq e 'del (.. | select (length == 0))')
|
||||
done
|
||||
fi
|
||||
|
||||
echo "$OUTPUT"
|
||||
16
yq/yq/Dockerfile
Normal file
16
yq/yq/Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
||||
# Container image that runs your code
|
||||
FROM debian:stable-slim
|
||||
|
||||
RUN apt update && apt install -y \
|
||||
wget
|
||||
|
||||
ARG VERSION=v4.30.6
|
||||
ARG BINARY=yq_linux_amd64
|
||||
|
||||
RUN wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O /usr/bin/yq && \
|
||||
chmod +x /usr/bin/yq
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
24
yq/yq/action.yaml
Normal file
24
yq/yq/action.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
name: yq
|
||||
description: "Run yq commands."
|
||||
inputs:
|
||||
command:
|
||||
description: "Shell arguments to pass into yq."
|
||||
required: true
|
||||
program:
|
||||
description: "Program to run instead of yq. Default: yq"
|
||||
required: false
|
||||
default: "yq"
|
||||
catchErrors:
|
||||
description: "Whether or not errors should be handled."
|
||||
required: false
|
||||
outputs:
|
||||
console:
|
||||
description: "The console output of the command."
|
||||
runs:
|
||||
env:
|
||||
PROGRAM: ${{ inputs.program }}
|
||||
CATCH_ERRORS: ${{ inputs.catchErrors }}
|
||||
using: docker
|
||||
image: Dockerfile
|
||||
args:
|
||||
- ${{ inputs.command }}
|
||||
27
yq/yq/entrypoint.sh
Normal file
27
yq/yq/entrypoint.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
COMMAND="$@"
|
||||
|
||||
# yq -p json -o yaml file.json # json -> yaml
|
||||
# yq -p json -o xml file.json # json -> xml
|
||||
# yq -p yaml -o json file.yaml # yaml -> json
|
||||
# yq -p yaml -o xml file.yaml # yaml -> xml
|
||||
# yq -p xml -o json file.xml # xml -> json
|
||||
# yq -p xml -o yaml file.xml # xml -> yaml
|
||||
#https://github.com/mikefarah/yq
|
||||
PROGRAM=${PROGRAM:-"yq"}
|
||||
OUTPUT=$(bash -c "$PROGRAM $COMMAND")
|
||||
RESULT=$?
|
||||
|
||||
#Output multiline strings.
|
||||
#https://trstringer.com/github-actions-multiline-strings/
|
||||
if [[ -n "$OUTPUT" ]]; then
|
||||
echo "console<<EOF" >> "$GITHUB_OUTPUT"
|
||||
echo "$OUTPUT" >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
echo "exitCode=$RESULT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
if [[ "$CATCH_ERRORS" != "true" ]]; then
|
||||
exit $RESULT
|
||||
fi
|
||||
Reference in New Issue
Block a user