This GitHub Action allows you to collect environment variables with a specific prefix and write them to a file. It is useful when you want to extract environment variables that match a certain pattern and save them to a .env file for deployment or configuration purposes.
- name: Collect environment variables
uses: ./action-tools/collect-env
with:
prefix: 'API_'
output: '.env.api'
remove-prefix: true| Name | Description | Required | Default |
|---|---|---|---|
| prefix | The prefix to filter environment variables by | true | - |
| output | The output file to write the collected variables to | true | - |
| remove-prefix | Whether to remove the prefix from variable names in the output | false | false |
This GitHub Action allows you to overwrite the contents of an environment file with the contents of another file. It is useful when you want to promote/stage environment variables from one environment to another (for example, from a .env.development file to a .env.production file) automatically in your workflows.
- name: Overwrite production env file with development env file
uses: ./action-tools/overwrite-env-file
with:
input: .env.development
output: .env.production| Name | Description | Required | Default |
|---|---|---|---|
| input | The file to read from | true | .env.development |
| output | The file to overwrite to | true | .env.production |
name: Promote env to production
on:
push:
branches: [main]
jobs:
promote-env:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Overwrite production env file with development env file
uses: ./actions/overwrite-env-file
with:
input: .env.development
output: .env.production