Skip to content
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
4 changes: 4 additions & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
paths:
.github/workflows/**/*.{yml,yaml}:
ignore:
- 'invalid runner name "node24" at runs.using'
9 changes: 5 additions & 4 deletions .github/workflows/labeler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ name: "PR Labeler"
on:
pull_request_target:

permissions:
pull-requests: write

jobs:
labeler:
name: "Labeler"
runs-on: ubuntu-latest
timeout-minutes: 5

permissions:
pull-requests: write
issues: write

steps:
- name: "Checkout Configs"
uses: actions/checkout@v5
Expand All @@ -36,7 +37,7 @@ jobs:

- name: "Label Creator"
continue-on-error: true
uses: cssnr/label-creator-action@master
uses: cssnr/label-creator-action@v1
with:
file: .configs/labels/labels.yaml

Expand Down
41 changes: 23 additions & 18 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
pull-requests: write

jobs:
lint:
name: "Lint"
runs-on: ubuntu-latest
timeout-minutes: 5

permissions:
pull-requests: write

steps:
- name: "Checkout"
uses: actions/checkout@v5
Expand Down Expand Up @@ -54,21 +54,26 @@ jobs:
echo "::endgroup::"
yamllint -d '${{ env.CONFIG }}' .

#- name: "Actionlint"
# if: ${{ !cancelled() }}
# run: |
# echo "::group::Download"
# loc=$(curl -sI https://github.com/rhysd/actionlint/releases/latest | grep -i '^location:')
# echo "loc: ${loc}"
# tag=$(echo "${loc}" | sed -E 's|.*/tag/v?(.*)|\1|' | tr -d '\t\r\n')
# echo "tag: ${tag}"
# url="https://github.com/rhysd/actionlint/releases/latest/download/actionlint_${tag}_linux_amd64.tar.gz"
# echo "url: ${url}"
# curl -sL "${url}" | tar xz -C "${RUNNER_TEMP}" actionlint
# file "${RUNNER_TEMP}/actionlint"
# "${RUNNER_TEMP}/actionlint" --version
# echo "::endgroup::"
# "${RUNNER_TEMP}/actionlint" -color -verbose -shellcheck= -pyflakes=
- name: "Actionlint"
if: ${{ !cancelled() }}
run: |
echo "::group::Download"
loc=$(curl -sI https://github.com/rhysd/actionlint/releases/latest | grep -i '^location:')
echo "loc: ${loc}"
tag=$(echo "${loc}" | sed -E 's|.*/tag/v?(.*)|\1|' | tr -d '\t\r\n')
echo "tag: ${tag}"
url="https://github.com/rhysd/actionlint/releases/latest/download/actionlint_${tag}_linux_amd64.tar.gz"
echo "url: ${url}"
curl -sL "${url}" | tar xz -C "${RUNNER_TEMP}" actionlint
file "${RUNNER_TEMP}/actionlint"
"${RUNNER_TEMP}/actionlint" --version
echo "::endgroup::"
"${RUNNER_TEMP}/actionlint" -color -verbose -shellcheck= -pyflakes=

- name: "Verify action.yml"
if: ${{ !cancelled() }}
run: |
yq -e '.runs.main | test("^dist/")' action.yml

- name: "Check Build Action"
if: ${{ !cancelled() }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
name: "Pull"
runs-on: ubuntu-latest
timeout-minutes: 5

permissions:
pull-requests: write

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
name: "Release"
runs-on: ubuntu-latest
timeout-minutes: 5

permissions:
contents: write

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
name: "Tags"
runs-on: ubuntu-latest
timeout-minutes: 5

permissions:
contents: write

Expand Down
40 changes: 25 additions & 15 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,51 @@ jobs:
- name: "Checkout"
uses: actions/checkout@v4

#- name: "Debug event.json"
# run: |
# cat "${GITHUB_EVENT_PATH}"
- name: "Debug CTX github"
if: ${{ !github.event.act }}
continue-on-error: true
env:
GITHUB_CTX: ${{ toJSON(github) }}
run: echo "$GITHUB_CTX"

- name: "1: Test to JSON"
- name: "1: Test: ENV -> JSON"
id: json
uses: ./
with:
source: ${{ env.ENV_FILE }}
dest: .github/test/results.json
summary: ${{ !github.event.act }}
source-data: ${{ env.ENV_FILE }}
#source-type: "env"
output-file: .github/test/results.json
#output-type: "json"

- name: "1: Verify JSON"
- name: "1: Verify: ENV -> JSON"
#if: ${{ !github.event.act }}
run: |
echo '${{ steps.json.outputs.result }}'
echo '--------'
cat .github/test/results.json
set -e
if [ '${{ steps.json.outputs.result }}' != "$(cat .github/test/results.json)" ];then
echo "JSON Verification Failed: results.json"
exit 1
fi

- name: "2: Test to Environment"
if: ${{ !github.event.act }}
- name: "2: Test: JSON -> ENV"
#if: ${{ !github.event.act }}
id: env
uses: ./
with:
source: ${{ env.JSON_FILE }}
dest: .github/test/results.env
type: "env"
summary: ${{ !github.event.act }}
source-data: ${{ env.JSON_FILE }}
source-type: "json"
output-file: .github/test/results.env
#output-type: "env"
sensitive: true

- name: "2: Verify Environment"
if: ${{ !github.event.act }}
- name: "2: Verify: JSON -> ENV"
#if: ${{ !github.event.act }}
run: |
echo '${{ steps.env.outputs.result }}'
echo '--------'
cat .github/test/results.env
if [ '${{ steps.env.outputs.result }}' != "$(cat .github/test/results.env)" ];then
echo "Environment Verification Failed: results.env"
Expand Down
89 changes: 58 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=cssnr_env-json-action&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=cssnr_env-json-action)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/cssnr/env-json-action?logo=github&label=updated)](https://github.com/cssnr/env-json-action/pulse)
[![Codeberg Last Commit](https://img.shields.io/gitea/last-commit/cssnr/env-json-action/master?gitea_url=https%3A%2F%2Fcodeberg.org%2F&logo=codeberg&logoColor=white&label=updated)](https://codeberg.org/cssnr/env-json-action)
[![GitHub Contributors](https://img.shields.io/github/contributors/cssnr/env-json-action?logo=github)](https://github.com/cssnr/env-json-action/graphs/contributors)
[![GitHub Contributors](https://img.shields.io/github/contributors-anon/cssnr/env-json-action?logo=github)](https://github.com/cssnr/env-json-action/graphs/contributors)
[![GitHub Repo Size](https://img.shields.io/github/repo-size/cssnr/env-json-action?logo=bookstack&logoColor=white&label=repo%20size)](https://github.com/cssnr/env-json-action?tab=readme-ov-file#readme)
[![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/env-json-action?logo=htmx)](https://github.com/cssnr/env-json-action)
[![GitHub Discussions](https://img.shields.io/github/discussions/cssnr/env-json-action?logo=github)](https://github.com/cssnr/env-json-action/discussions)
Expand All @@ -23,30 +23,63 @@
- [Inputs](#Inputs)
- [Outputs](#Outputs)
- [Examples](#Examples)
- [Tags](#Tags)
- [Support](#Support)
- [Contributing](#Contributing)

Convert an Environment File to or from JSON for Outputs or Writing to a File.
Convert Environment File, Data or Keys, to or from, JSON Data or File.

Also allows masking the data as secret (only viable for source files since inputs are exposed).

> [!NOTE]
> Please submit a [Feature Request](https://github.com/cssnr/env-json-action/discussions/categories/feature-requests)
> for new features or [Open an Issue](https://github.com/cssnr/env-json-action/issues) if you find any bugs.

## Inputs

| input | required | default | description |
| --------- | :------: | ------- | ------------------------------------ |
| source | **Yes** | - | Source Environment or JSON File Path |
| type | - | `json` | Output Type: [`json`, `env`] \* |
| dest | - | - | Optional File to Write Data Too |
| sensitive | - | `false` | Sensitive Data \* |
| summary | - | `true` | Add Summary to Job \* |
| Input | Default | Description of Input |
| :-------------------------- | :--------: | :--------------------------------- |
| [source-data](#source-data) | _Required_ | Source Data or File Path |
| [source-type](#source-type) | `json` | Source Type: [`json`, `env`] |
| [output-type](#output-type) | _Opposite_ | Output Type: [`json`, `env`] |
| [output-file](#output-file) | - | Optional File to Write Output Data |
| [sensitive](#sensitive) | `false` | Mark Output Data as Sensitive |
| [summary](#summary) | `true` | Add Summary to Job |

#### source-data

Source Environment or JSON Data or File Path.

_Previously:_ `source`

#### source-type

Source Data Type,
one of: [`json`, `env`]

_Previously:_ `type`

#### output-type

Output Data Type,defaults to the opposite of `source-type`,
one of: [`json`, `env`]

_Previously:_ `output`

**type** - By default this converts env to json. To perform json to env, use type `env`.
#### output-file

**sensitive** - Set to `true` if data is sensitive and should be masked.
Optional File Path to Write the Output Data.

**summary** - Write a Summary for the job. To disable this set to `false`.
_Previously:_ `file`

#### sensitive

Set to `true` if data is sensitive and should be masked.
This will mask the data as a whole, plus every individual value.

#### summary

Write a Summary for the job. To disable this set to `false`.

<details><summary>👀 View Example Summary</summary>

Expand Down Expand Up @@ -75,21 +108,21 @@ To see a workflow run you can view a recent
- name: 'Parse Environment'
uses: cssnr/env-json-action@master
with:
source: test.env
source-data: test.env
```

## Outputs

| output | description |
| ------ | --------------------------- |
| Output | Description |
| :----- | :-------------------------- |
| result | JSON or Environment Results |

```yaml
- name: 'Parse Environment'
id: parse
uses: cssnr/env-json-action@master
with:
source: test.env
source-data: test.env

- name: 'Echo Result'
run: echo '${{ steps.parse.outputs.result }}'
Expand All @@ -99,9 +132,6 @@ To see a workflow run you can view a recent

There are some more examples in the test workflow: [.github/workflows/test.yaml](.github/workflows/test.yaml)

For a full deploy workflow example, see:
https://github.com/cssnr/django5-boiler/blob/master/.github/workflows/deploy.yaml

For more examples, you can check out other projects using this action:
https://github.com/cssnr/env-json-action/network/dependents

Expand Down Expand Up @@ -147,38 +177,35 @@ If you would like to submit a PR, please review the [CONTRIBUTING.md](#contribut
Additionally, you can support other GitHub Actions I have published:

- [Stack Deploy Action](https://github.com/cssnr/stack-deploy-action?tab=readme-ov-file#readme)
- [Portainer Stack Deploy](https://github.com/cssnr/portainer-stack-deploy-action?tab=readme-ov-file#readme)
- [Portainer Stack Deploy Action](https://github.com/cssnr/portainer-stack-deploy-action?tab=readme-ov-file#readme)
- [Docker Context Action](https://github.com/cssnr/docker-context-action?tab=readme-ov-file#readme)
- [VirusTotal Action](https://github.com/cssnr/virustotal-action?tab=readme-ov-file#readme)
- [Mirror Repository Action](https://github.com/cssnr/mirror-repository-action?tab=readme-ov-file#readme)
- [Update Version Tags Action](https://github.com/cssnr/update-version-tags-action?tab=readme-ov-file#readme)
- [Docker Tags Action](https://github.com/cssnr/docker-tags-action?tab=readme-ov-file#readme)
- [Update JSON Value Action](https://github.com/cssnr/update-json-value-action?tab=readme-ov-file#readme)
- [JSON Key Value Check Action](https://github.com/cssnr/json-key-value-check-action?tab=readme-ov-file#readme)
- [Parse Issue Form Action](https://github.com/cssnr/parse-issue-form-action?tab=readme-ov-file#readme)
- [Cloudflare Purge Cache Action](https://github.com/cssnr/cloudflare-purge-cache-action?tab=readme-ov-file#readme)
- [Mozilla Addon Update Action](https://github.com/cssnr/mozilla-addon-update-action?tab=readme-ov-file#readme)
- [Docker Tags Action](https://github.com/cssnr/docker-tags-action?tab=readme-ov-file#readme)
- [Package Changelog Action](https://github.com/cssnr/package-changelog-action?tab=readme-ov-file#readme)
- [NPM Outdated Check Action](https://github.com/cssnr/npm-outdated-action?tab=readme-ov-file#readme)
- [Label Creator Action](https://github.com/cssnr/label-creator-action?tab=readme-ov-file#readme)
- [Algolia Crawler Action](https://github.com/cssnr/algolia-crawler-action?tab=readme-ov-file#readme)
- [Upload Release Action](https://github.com/cssnr/upload-release-action?tab=readme-ov-file#readme)
- [Check Build Action](https://github.com/cssnr/check-build-action?tab=readme-ov-file#readme)
- [Web Request Action](https://github.com/cssnr/web-request-action?tab=readme-ov-file#readme)
- [Get Commit Action](https://github.com/cssnr/get-commit-action?tab=readme-ov-file#readme)

<details><summary>❔ Unpublished Actions</summary>

These actions are not published on the Marketplace, but may be useful.

Generic Actions:

- [cssnr/draft-release-action](https://github.com/cssnr/draft-release-action) - Keep a draft release ready to publish.
- [cssnr/env-json-action](https://github.com/cssnr/env-json-action) - Convert env file to json or vice versa.
- [cssnr/get-commit-action](https://github.com/cssnr/get-commit-action) - Get the current commit with full details.

Specific Actions:

- [cssnr/push-artifacts-action](https://github.com/cssnr/push-artifacts-action) - Sync's artifacts to a remote host.
- [smashedr/update-release-notes-action](https://github.com/smashedr/update-release-notes-action) - Update release notes.
- [cssnr/draft-release-action](https://github.com/cssnr/draft-release-action?tab=readme-ov-file#readme) - Keep a draft release ready to publish.
- [cssnr/env-json-action](https://github.com/cssnr/env-json-action?tab=readme-ov-file#readme) - Convert env file to json or vice versa.
- [cssnr/push-artifacts-action](https://github.com/cssnr/push-artifacts-action?tab=readme-ov-file#readme) - Sync files to a remote host with rsync.
- [smashedr/update-release-notes-action](https://github.com/smashedr/update-release-notes-action?tab=readme-ov-file#readme) - Update release notes.
- [smashedr/combine-release-notes-action](https://github.com/smashedr/combine-release-notes-action?tab=readme-ov-file#readme) - Combine release notes.

---

Expand Down
23 changes: 15 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,30 @@ branding:
color: "green"

inputs:
source:
description: "Source File Path"
source-data:
description: "Source Data or File Path"
required: true
source:
description: "Source Data or File Path"
deprecationMessage: "Input has changed to: source-type"
source-type:
description: "Source Type"
default: "env"
type:
description: "Source Type"
deprecationMessage: "Input has changed to: source-type"
output-type:
description: "Output Type"
required: false
default: "json"
output-file:
description: "Output File Path"
dest:
description: "Output File"
required: false
description: "Output File Path"
deprecationMessage: "Input has changed to: output-file"
sensitive:
description: "Sensitive Data"
required: false
default: "false"
summary:
description: "Add Summary to Job"
required: false
default: "true"

outputs:
Expand Down
Loading