Skip to content

Commit

Permalink
feat: create export-secrets-action
Browse files Browse the repository at this point in the history
  • Loading branch information
koyashiro committed Apr 13, 2024
1 parent f698798 commit f0c7124
Show file tree
Hide file tree
Showing 18 changed files with 34,765 additions and 2 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
30 changes: 30 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** @type {import("eslint/lib/shared/types").ConfigData} */
module.exports = {
env: {
es2021: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script",
},
},
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["@typescript-eslint"],
rules: {},
};
21 changes: 21 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: actionlint

on:
push:
branches:
- main
pull_request:

jobs:
actionlint:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Download actionlint
id: get_actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
shell: bash
- name: Check workflow files
run: ${{ steps.get_actionlint.outputs.executable }} -color
shell: bash
122 changes: 122 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: ci

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version-file: package.json
cache: npm
- name: Run npm ci
run: npm ci
- name: Build
run: npm run build
- name: Check diff
run: |
if ! git diff --no-patch --exit-code; then
echo Diff found 1>&2
exit 1
fi
lint:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version-file: package.json
cache: npm
- name: Run npm ci
run: npm ci
- name: Run ESLint
run: npm run lint

format:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version-file: package.json
cache: npm
- name: Run npm ci
run: npm ci
- name: Run Prettier format check
run: npm run format:check

test-node:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version-file: package.json
cache: npm
- name: Run npm ci
run: npm ci
- name: Test
run: npm test

test-action:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Run export-secrets-action
uses: ./
with:
secrets: '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C"}'
- name: Check environment variables
run: |
EXPECTED_VALUE_KEY_A='VALUE_A'
EXPECTED_VALUE_KEY_B='VALUE_B'
EXPECTED_VALUE_KEY_C='VALUE_C'
FAILED='false'
if [ "$KEY_A" = "$EXPECTED_VALUE_KEY_A" ]; then
echo 'PASSED: VALUE_A'
else
echo 'FAILED: VALUE_A' 1>&2
echo " expected: $EXPECTED_VALUE_KEY_A" 1>&2
echo " actual: $KEY_A" 1>&2
FAILED='true'
fi
if [ "$KEY_B" = "$EXPECTED_VALUE_KEY_B" ]; then
echo 'PASSED: VALUE_B'
else
echo 'FAILED: VALUE_B' 1>&2
echo " expected: $EXPECTED_VALUE_KEY_B" 1>&2
echo " actual: $KEY_B" 1>&2
FAILED='true'
fi
if [ "$KEY_C" = "$EXPECTED_VALUE_KEY_C" ]; then
echo 'PASSED: VALUE_C'
else
echo 'FAILED: VALUE_C' 1>&2
echo " expected: $EXPECTED_VALUE_KEY_C" 1>&2
echo " actual: $KEY_C" 1>&2
FAILED='true'
fi
if [ "$FAILED" = 'true' ]; then
exit 1
fi
16 changes: 16 additions & 0 deletions .github/workflows/renovate-config-validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: renovate-config-validator

on:
push:
branches:
- main
pull_request:

jobs:
renovate-config-validator:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Run renovate-config-validator
uses: suzuki-shunsuke/github-action-renovate-config-validator@b54483862375f51910a60c4f498e927d4f3df466 # v1.0.1
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ out

# Nuxt.js build / generate output
.nuxt
dist
# dist

# Gatsby files
.cache/
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# export-secrets-action
# export-secrets-action

Export GitHub Actions secrets as environment variables.

## Usage

```yml
steps:
- uses: koyashiro/[email protected]
with:
secrets: ${{ toJSON(secrets) }}
```
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: export-secrets-action
author: koyashiro <[email protected]>
description: Export GitHub Actions secrets as environment variables
inputs:
secrets:
description: JSON representation of secrets
required: true
runs:
using: node20
main: dist/index.js
Loading

0 comments on commit f0c7124

Please sign in to comment.