diff --git a/remote-loader/README.md b/remote-loader/README.md index 4121cfe..6286e7f 100644 --- a/remote-loader/README.md +++ b/remote-loader/README.md @@ -6,6 +6,10 @@ This is useful if you want to store your encrypted dotenv files in a separate re Note that releases for this action follow the same release cycle and cadence as the main action itself. +## Prerequisites + +The only prerequisites to use this composite action are `jq` (for parsing JSON) and `curl` (for fetching remote files), both of which are pre-installed in the default GitHub Actions runners. + ## Usage ```yaml @@ -16,6 +20,12 @@ Note that releases for this action follow the same release cycle and cadence as key: ${{ secrets.DOTENV_PRIVATE_KEY_CI }} # for .env.ci # optional if you need them in scripts involve requiring access to secrets via env vars # inject-env-vars: "true" + +# To access the resulting outputs, use the `fromJson` function to parse the JSON-encoded output. +- name: Workaround for accessing outputs as JSON + run: gh auth status + env: + GH_PAT: ${{ fromJson(steps.dotenvx.outputs.DOTENV_RESULT).GH_PAT }} ``` ### Inputs @@ -28,6 +38,14 @@ Other than [the regular options in the main action itself](../README.md#inputs), Because this action fetches the dotenv file from a remote URL, you may need to ensure that the URL is accessible from the GitHub Actions runner environment (or utilize Actions secrets for adding URLs with any sensitive information in it, e.g. API keys in URL parameters). +### Outputs + +Other than the regular outputs in the main action itself, this action also provides: + +| Output | Description | +| -------------------- | --------------------------------------------------------------------------------------- | +| `DOTENV_RESULT` | JSON-encoded result of the dotenvx decryption operation, use `fromJson` to access them. | + ## License MIT diff --git a/remote-loader/action.yml b/remote-loader/action.yml index c77bb49..1bf7845 100644 --- a/remote-loader/action.yml +++ b/remote-loader/action.yml @@ -16,6 +16,20 @@ inputs: description: Whether to inject decrypted secrets as environment variables for subsequent steps within the runner environment default: "false" +outputs: + DOTENV_KEYS_LOADED: + value: ${{ steps.loader.outputs.DOTENV_KEYS_LOADED }} + description: Operates similarly with `CI` and friends + DOTENV_DECRYPTION_FAILURE: + value: ${{ steps.loader.outputs.DOTENV_DECRYPTION_FAILURE }} + description: Whether there are failed secret decryptions or not + DOTENV_DECRYPTION_FAIL_COUNT: + value: ${{ steps.loader.outputs.DOTENV_DECRYPTION_FAIL_COUNT }} + description: Number of failed secret decryptions + DOTENV_RESULT: + description: JSON-encoded result of the dotenvx decryption operation + value: ${{ steps.results.outputs.data }} + runs: using: composite steps: @@ -40,8 +54,15 @@ runs: echo "Remote dotenv file fetched successfully." echo "path=/tmp/remote_env_file" >> $GITHUB_OUTPUT - name: Load dotenvx secrets + id: loader uses: andreijiroh-dev/dotenvx-action@v0.4.0 with: path: ${{ steps.fetch.outputs.path }} key: ${{ inputs.key }} inject-env-vars: ${{ inputs.inject-env-vars }} + + - name: Output dotenvx results for use + id: results + shell: bash + run: | + echo "data=$(jq -n --arg data \"${{ steps.loader.outputs }}\" '$data | fromjson')" >> $GITHUB_OUTPUT