Skip to content

Commit 100077f

Browse files
committed
Update
1 parent 572a64f commit 100077f

File tree

3 files changed

+145
-6
lines changed

3 files changed

+145
-6
lines changed

README.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
# Action Tools
22

33
## Actions
4+
5+
### Collect Env
6+
7+
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.
8+
9+
#### Usage
10+
11+
```yaml
12+
- name: Collect environment variables
13+
uses: ./action-tools/collect-env
14+
with:
15+
prefix: 'API_'
16+
output: '.env.api'
17+
remove-prefix: true
18+
```
19+
20+
#### Inputs
21+
22+
| Name | Description | Required | Default |
23+
|------|-------------|----------|---------|
24+
| prefix | The prefix to filter environment variables by | true | - |
25+
| output | The output file to write the collected variables to | true | - |
26+
| remove-prefix | Whether to remove the prefix from variable names in the output | false | false |
27+
428
### Overwrite Env File
529
630
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.
@@ -11,16 +35,16 @@ This GitHub Action allows you to overwrite the contents of an environment file w
1135
- name: Overwrite production env file with development env file
1236
uses: ./action-tools/overwrite-env-file
1337
with:
14-
input-file: .env.development
15-
output-file: .env.production
38+
input: .env.development
39+
output: .env.production
1640
```
1741

1842
#### Inputs
1943

2044
| Name | Description | Required | Default |
2145
|--------------|------------------------------|----------|---------------------|
22-
| input-file | The file to read from | true | .env.development |
23-
| output-file | The file to overwrite to | true | .env.production |
46+
| input | The file to read from | true | .env.development |
47+
| output | The file to overwrite to | true | .env.production |
2448

2549
#### Example Workflow
2650

@@ -41,7 +65,7 @@ jobs:
4165
- name: Overwrite production env file with development env file
4266
uses: ./actions/overwrite-env-file
4367
with:
44-
input-file: .env.development
45-
output-file: .env.production
68+
input: .env.development
69+
output: .env.production
4670
```
4771

actions/collect-env/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
### Collect Env
2+
3+
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.
4+
5+
#### Usage
6+
7+
```yaml
8+
- name: Collect environment variables
9+
uses: ./action-tools/collect-env
10+
with:
11+
prefix: 'API_'
12+
output: '.env.api'
13+
remove-prefix: true
14+
```
15+
16+
#### Inputs
17+
18+
| Name | Description | Required | Default |
19+
|------|-------------|----------|---------|
20+
| prefix | The prefix to filter environment variables by | true | - |
21+
| output | The output file to write the collected variables to | true | - |
22+
| remove-prefix | Whether to remove the prefix from variable names in the output | false | false |
23+
24+
#### Example Workflow
25+
26+
```yaml
27+
name: Collect API environment variables
28+
29+
on:
30+
push:
31+
branches: [main]
32+
33+
jobs:
34+
collect-env:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
40+
- name: Collect API environment variables
41+
uses: ./actions/collect-env
42+
with:
43+
prefix: 'API_'
44+
output: '.env.api'
45+
remove-prefix: true
46+
```
47+
48+
#### Example
49+
50+
If you have the following environment variables:
51+
- `API_KEY=secret123`
52+
- `API_URL=https://api.example.com`
53+
- `API_TIMEOUT=5000`
54+
- `DATABASE_URL=postgres://localhost`
55+
56+
And you run the action with:
57+
- `prefix: 'API_'`
58+
- `remove-prefix: true`
59+
60+
The output file will contain:
61+
```
62+
KEY=secret123
63+
URL=https://api.example.com
64+
TIMEOUT=5000
65+
```
66+
67+
If `remove-prefix: false`, the output will be:
68+
```
69+
API_KEY=secret123
70+
API_URL=https://api.example.com
71+
API_TIMEOUT=5000
72+
```
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
### Overwrite Env File
2+
3+
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.
4+
5+
#### Usage
6+
7+
```yaml
8+
- name: Overwrite production env file with development env file
9+
uses: ./action-tools/overwrite-env-file
10+
with:
11+
input: .env.development
12+
output: .env.production
13+
```
14+
15+
#### Inputs
16+
17+
| Name | Description | Required | Default |
18+
|--------------|------------------------------|----------|---------------------|
19+
| input | The file to read from | true | .env.development |
20+
| output | The file to overwrite to | true | .env.production |
21+
22+
#### Example Workflow
23+
24+
```yaml
25+
name: Promote env to production
26+
27+
on:
28+
push:
29+
branches: [main]
30+
31+
jobs:
32+
promote-env:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
38+
- name: Overwrite production env file with development env file
39+
uses: ./actions/overwrite-env-file
40+
with:
41+
input: .env.development
42+
output: .env.production
43+
```

0 commit comments

Comments
 (0)