Skip to content

Commit 065abd1

Browse files
authored
Overhaul Action (#7)
1 parent 25ebb34 commit 065abd1

File tree

13 files changed

+415
-269
lines changed

13 files changed

+415
-269
lines changed

.github/actionlint.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
paths:
2+
.github/workflows/**/*.{yml,yaml}:
3+
ignore:
4+
- 'invalid runner name "node24" at runs.using'

.github/workflows/labeler.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ name: "PR Labeler"
33
on:
44
pull_request_target:
55

6-
permissions:
7-
pull-requests: write
8-
96
jobs:
107
labeler:
118
name: "Labeler"
129
runs-on: ubuntu-latest
1310
timeout-minutes: 5
1411

12+
permissions:
13+
pull-requests: write
14+
issues: write
15+
1516
steps:
1617
- name: "Checkout Configs"
1718
uses: actions/checkout@v5
@@ -36,7 +37,7 @@ jobs:
3637
3738
- name: "Label Creator"
3839
continue-on-error: true
39-
uses: cssnr/label-creator-action@master
40+
uses: cssnr/label-creator-action@v1
4041
with:
4142
file: .configs/labels/labels.yaml
4243

.github/workflows/lint.yaml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13-
permissions:
14-
pull-requests: write
15-
1613
jobs:
1714
lint:
1815
name: "Lint"
1916
runs-on: ubuntu-latest
2017
timeout-minutes: 5
2118

19+
permissions:
20+
pull-requests: write
21+
2222
steps:
2323
- name: "Checkout"
2424
uses: actions/checkout@v5
@@ -54,21 +54,26 @@ jobs:
5454
echo "::endgroup::"
5555
yamllint -d '${{ env.CONFIG }}' .
5656
57-
#- name: "Actionlint"
58-
# if: ${{ !cancelled() }}
59-
# run: |
60-
# echo "::group::Download"
61-
# loc=$(curl -sI https://github.com/rhysd/actionlint/releases/latest | grep -i '^location:')
62-
# echo "loc: ${loc}"
63-
# tag=$(echo "${loc}" | sed -E 's|.*/tag/v?(.*)|\1|' | tr -d '\t\r\n')
64-
# echo "tag: ${tag}"
65-
# url="https://github.com/rhysd/actionlint/releases/latest/download/actionlint_${tag}_linux_amd64.tar.gz"
66-
# echo "url: ${url}"
67-
# curl -sL "${url}" | tar xz -C "${RUNNER_TEMP}" actionlint
68-
# file "${RUNNER_TEMP}/actionlint"
69-
# "${RUNNER_TEMP}/actionlint" --version
70-
# echo "::endgroup::"
71-
# "${RUNNER_TEMP}/actionlint" -color -verbose -shellcheck= -pyflakes=
57+
- name: "Actionlint"
58+
if: ${{ !cancelled() }}
59+
run: |
60+
echo "::group::Download"
61+
loc=$(curl -sI https://github.com/rhysd/actionlint/releases/latest | grep -i '^location:')
62+
echo "loc: ${loc}"
63+
tag=$(echo "${loc}" | sed -E 's|.*/tag/v?(.*)|\1|' | tr -d '\t\r\n')
64+
echo "tag: ${tag}"
65+
url="https://github.com/rhysd/actionlint/releases/latest/download/actionlint_${tag}_linux_amd64.tar.gz"
66+
echo "url: ${url}"
67+
curl -sL "${url}" | tar xz -C "${RUNNER_TEMP}" actionlint
68+
file "${RUNNER_TEMP}/actionlint"
69+
"${RUNNER_TEMP}/actionlint" --version
70+
echo "::endgroup::"
71+
"${RUNNER_TEMP}/actionlint" -color -verbose -shellcheck= -pyflakes=
72+
73+
- name: "Verify action.yml"
74+
if: ${{ !cancelled() }}
75+
run: |
76+
yq -e '.runs.main | test("^dist/")' action.yml
7277
7378
- name: "Check Build Action"
7479
if: ${{ !cancelled() }}

.github/workflows/pull.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
name: "Pull"
1313
runs-on: ubuntu-latest
1414
timeout-minutes: 5
15+
1516
permissions:
1617
pull-requests: write
1718

.github/workflows/release.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
name: "Release"
1010
runs-on: ubuntu-latest
1111
timeout-minutes: 5
12+
1213
permissions:
1314
contents: write
1415

.github/workflows/tags.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
name: "Tags"
1313
runs-on: ubuntu-latest
1414
timeout-minutes: 5
15+
1516
permissions:
1617
contents: write
1718

.github/workflows/test.yaml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,41 +22,51 @@ jobs:
2222
- name: "Checkout"
2323
uses: actions/checkout@v4
2424

25-
#- name: "Debug event.json"
26-
# run: |
27-
# cat "${GITHUB_EVENT_PATH}"
25+
- name: "Debug CTX github"
26+
if: ${{ !github.event.act }}
27+
continue-on-error: true
28+
env:
29+
GITHUB_CTX: ${{ toJSON(github) }}
30+
run: echo "$GITHUB_CTX"
2831

29-
- name: "1: Test to JSON"
32+
- name: "1: Test: ENV -> JSON"
3033
id: json
3134
uses: ./
3235
with:
33-
source: ${{ env.ENV_FILE }}
34-
dest: .github/test/results.json
36+
summary: ${{ !github.event.act }}
37+
source-data: ${{ env.ENV_FILE }}
38+
#source-type: "env"
39+
output-file: .github/test/results.json
40+
#output-type: "json"
3541

36-
- name: "1: Verify JSON"
42+
- name: "1: Verify: ENV -> JSON"
43+
#if: ${{ !github.event.act }}
3744
run: |
3845
echo '${{ steps.json.outputs.result }}'
46+
echo '--------'
3947
cat .github/test/results.json
40-
set -e
4148
if [ '${{ steps.json.outputs.result }}' != "$(cat .github/test/results.json)" ];then
4249
echo "JSON Verification Failed: results.json"
4350
exit 1
4451
fi
4552
46-
- name: "2: Test to Environment"
47-
if: ${{ !github.event.act }}
53+
- name: "2: Test: JSON -> ENV"
54+
#if: ${{ !github.event.act }}
4855
id: env
4956
uses: ./
5057
with:
51-
source: ${{ env.JSON_FILE }}
52-
dest: .github/test/results.env
53-
type: "env"
58+
summary: ${{ !github.event.act }}
59+
source-data: ${{ env.JSON_FILE }}
60+
source-type: "json"
61+
output-file: .github/test/results.env
62+
#output-type: "env"
5463
sensitive: true
5564

56-
- name: "2: Verify Environment"
57-
if: ${{ !github.event.act }}
65+
- name: "2: Verify: JSON -> ENV"
66+
#if: ${{ !github.event.act }}
5867
run: |
5968
echo '${{ steps.env.outputs.result }}'
69+
echo '--------'
6070
cat .github/test/results.env
6171
if [ '${{ steps.env.outputs.result }}' != "$(cat .github/test/results.env)" ];then
6272
echo "Environment Verification Failed: results.env"

README.md

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![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)
99
[![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)
1010
[![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)
11-
[![GitHub Contributors](https://img.shields.io/github/contributors/cssnr/env-json-action?logo=github)](https://github.com/cssnr/env-json-action/graphs/contributors)
11+
[![GitHub Contributors](https://img.shields.io/github/contributors-anon/cssnr/env-json-action?logo=github)](https://github.com/cssnr/env-json-action/graphs/contributors)
1212
[![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)
1313
[![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/env-json-action?logo=htmx)](https://github.com/cssnr/env-json-action)
1414
[![GitHub Discussions](https://img.shields.io/github/discussions/cssnr/env-json-action?logo=github)](https://github.com/cssnr/env-json-action/discussions)
@@ -23,30 +23,63 @@
2323
- [Inputs](#Inputs)
2424
- [Outputs](#Outputs)
2525
- [Examples](#Examples)
26+
- [Tags](#Tags)
2627
- [Support](#Support)
2728
- [Contributing](#Contributing)
2829

29-
Convert an Environment File to or from JSON for Outputs or Writing to a File.
30+
Convert Environment File, Data or Keys, to or from, JSON Data or File.
31+
32+
Also allows masking the data as secret (only viable for source files since inputs are exposed).
3033

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

37-
| input | required | default | description |
38-
| --------- | :------: | ------- | ------------------------------------ |
39-
| source | **Yes** | - | Source Environment or JSON File Path |
40-
| type | - | `json` | Output Type: [`json`, `env`] \* |
41-
| dest | - | - | Optional File to Write Data Too |
42-
| sensitive | - | `false` | Sensitive Data \* |
43-
| summary | - | `true` | Add Summary to Job \* |
40+
| Input | Default | Description of Input |
41+
| :-------------------------- | :--------: | :--------------------------------- |
42+
| [source-data](#source-data) | _Required_ | Source Data or File Path |
43+
| [source-type](#source-type) | `json` | Source Type: [`json`, `env`] |
44+
| [output-type](#output-type) | _Opposite_ | Output Type: [`json`, `env`] |
45+
| [output-file](#output-file) | - | Optional File to Write Output Data |
46+
| [sensitive](#sensitive) | `false` | Mark Output Data as Sensitive |
47+
| [summary](#summary) | `true` | Add Summary to Job |
48+
49+
#### source-data
50+
51+
Source Environment or JSON Data or File Path.
52+
53+
_Previously:_ `source`
54+
55+
#### source-type
56+
57+
Source Data Type,
58+
one of: [`json`, `env`]
59+
60+
_Previously:_ `type`
61+
62+
#### output-type
63+
64+
Output Data Type,defaults to the opposite of `source-type`,
65+
one of: [`json`, `env`]
66+
67+
_Previously:_ `output`
4468

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

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

49-
**summary** - Write a Summary for the job. To disable this set to `false`.
73+
_Previously:_ `file`
74+
75+
#### sensitive
76+
77+
Set to `true` if data is sensitive and should be masked.
78+
This will mask the data as a whole, plus every individual value.
79+
80+
#### summary
81+
82+
Write a Summary for the job. To disable this set to `false`.
5083

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

@@ -75,21 +108,21 @@ To see a workflow run you can view a recent
75108
- name: 'Parse Environment'
76109
uses: cssnr/env-json-action@master
77110
with:
78-
source: test.env
111+
source-data: test.env
79112
```
80113
81114
## Outputs
82115
83-
| output | description |
84-
| ------ | --------------------------- |
116+
| Output | Description |
117+
| :----- | :-------------------------- |
85118
| result | JSON or Environment Results |
86119
87120
```yaml
88121
- name: 'Parse Environment'
89122
id: parse
90123
uses: cssnr/env-json-action@master
91124
with:
92-
source: test.env
125+
source-data: test.env
93126

94127
- name: 'Echo Result'
95128
run: echo '${{ steps.parse.outputs.result }}'
@@ -99,9 +132,6 @@ To see a workflow run you can view a recent
99132
100133
There are some more examples in the test workflow: [.github/workflows/test.yaml](.github/workflows/test.yaml)
101134
102-
For a full deploy workflow example, see:
103-
https://github.com/cssnr/django5-boiler/blob/master/.github/workflows/deploy.yaml
104-
105135
For more examples, you can check out other projects using this action:
106136
https://github.com/cssnr/env-json-action/network/dependents
107137
@@ -147,38 +177,35 @@ If you would like to submit a PR, please review the [CONTRIBUTING.md](#contribut
147177
Additionally, you can support other GitHub Actions I have published:
148178

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

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

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

172-
Generic Actions:
173-
174-
- [cssnr/draft-release-action](https://github.com/cssnr/draft-release-action) - Keep a draft release ready to publish.
175-
- [cssnr/env-json-action](https://github.com/cssnr/env-json-action) - Convert env file to json or vice versa.
176-
- [cssnr/get-commit-action](https://github.com/cssnr/get-commit-action) - Get the current commit with full details.
177-
178-
Specific Actions:
179-
180-
- [cssnr/push-artifacts-action](https://github.com/cssnr/push-artifacts-action) - Sync's artifacts to a remote host.
181-
- [smashedr/update-release-notes-action](https://github.com/smashedr/update-release-notes-action) - Update release notes.
204+
- [cssnr/draft-release-action](https://github.com/cssnr/draft-release-action?tab=readme-ov-file#readme) - Keep a draft release ready to publish.
205+
- [cssnr/env-json-action](https://github.com/cssnr/env-json-action?tab=readme-ov-file#readme) - Convert env file to json or vice versa.
206+
- [cssnr/push-artifacts-action](https://github.com/cssnr/push-artifacts-action?tab=readme-ov-file#readme) - Sync files to a remote host with rsync.
207+
- [smashedr/update-release-notes-action](https://github.com/smashedr/update-release-notes-action?tab=readme-ov-file#readme) - Update release notes.
208+
- [smashedr/combine-release-notes-action](https://github.com/smashedr/combine-release-notes-action?tab=readme-ov-file#readme) - Combine release notes.
182209

183210
---
184211

action.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,30 @@ branding:
66
color: "green"
77

88
inputs:
9-
source:
10-
description: "Source File Path"
9+
source-data:
10+
description: "Source Data or File Path"
1111
required: true
12+
source:
13+
description: "Source Data or File Path"
14+
deprecationMessage: "Input has changed to: source-type"
15+
source-type:
16+
description: "Source Type"
17+
default: "env"
1218
type:
19+
description: "Source Type"
20+
deprecationMessage: "Input has changed to: source-type"
21+
output-type:
1322
description: "Output Type"
14-
required: false
15-
default: "json"
23+
output-file:
24+
description: "Output File Path"
1625
dest:
17-
description: "Output File"
18-
required: false
26+
description: "Output File Path"
27+
deprecationMessage: "Input has changed to: output-file"
1928
sensitive:
2029
description: "Sensitive Data"
21-
required: false
2230
default: "false"
2331
summary:
2432
description: "Add Summary to Job"
25-
required: false
2633
default: "true"
2734

2835
outputs:

0 commit comments

Comments
 (0)