GitHub Action
Pull secrets into .env files during a GitHub Actions workflow.
GitHub Action setup
The prebuilt Envilder GitHub Action pulls secrets from AWS SSM or Azure Key Vault into .env files during your CI/CD workflow. Use the published macalbert/envilder/github-action@v0 tag; no consumer build step is required.
Prerequisites
- AWS: Configure credentials with aws-actions/configure-aws-credentials
- Azure: Configure credentials with azure/login
- An envilder.json committed to your repository
The GitHub Action only supports pull mode (no push).
Basic workflow example
.github/workflows/deploy.ymlyaml
name: Deploy Application
on:
push:
branches: [main]
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Pull Secrets from AWS SSM
uses: macalbert/envilder/github-action@v0
with:
map-file: config/envilder.json
env-file: .env
- uses: actions/setup-node@v6
with:
node-version: "22.x"
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: pnpm deployAzure Key Vault workflow
.github/workflows/deploy-azure.ymlyaml
name: Deploy with Azure Key Vault
on:
push:
branches: [main]
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Pull Secrets from Azure Key Vault
uses: macalbert/envilder/github-action@v0
with:
map-file: config/envilder.json
env-file: .env
provider: azure
vault-url: https://my-vault.vault.azure.net
- uses: actions/setup-node@v6
with:
node-version: "22.x"
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: pnpm deployMulti-environment workflow
.github/workflows/deploy-env.ymlyaml
name: Deploy to Environment
on:
workflow_dispatch:
inputs:
environment:
description: 'Target environment'
required: true
type: choice
options: [dev, staging, production]
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-24.04
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v5
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Pull ${{ inputs.environment }} secrets
uses: macalbert/envilder/github-action@v0
with:
map-file: config/${{ inputs.environment }}/envilder.json
env-file: .env
- uses: actions/setup-node@v6
with:
node-version: "22.x"
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: pnpm deployAction inputs & outputs
Inputs
| Input | Required | Default | Description |
|---|---|---|---|
map-file | Yes | - | Path to JSON mapping file |
env-file | Yes | - | Path to the .env file to generate |
provider | No | aws | aws or azure |
vault-url | No | - | Azure Key Vault URL |
Outputs
| Output | Description |
|---|---|
env-file-path | Path to the generated .env file |