File tree Expand file tree Collapse file tree 4 files changed +62
-2
lines changed
Expand file tree Collapse file tree 4 files changed +62
-2
lines changed Original file line number Diff line number Diff line change 1- name : ' built -test-deploy'
1+ name : ' build -test-deploy'
22on :
33 pull_request :
44 paths-ignore :
9191 ACTION_CREATE_ENV_TEST : 1
9292 - run : cat .env
9393 - run : grep -zP "^PROD=0\nTEST=1$" .env
94+ test-skip-env-vars-when-include_env_vars-disabled :
95+ runs-on : ubuntu-latest
96+ needs :
97+ - build
98+ steps :
99+ - uses : actions/checkout@v2
100+ - uses : actions/download-artifact@v2
101+ with :
102+ name : dist
103+ path : dist
104+ - uses : ./
105+ with :
106+ full_text : PROD=0
107+ env :
108+ ACTION_CREATE_ENV_TEST : 1
109+ - run : cat .env
110+ - run : grep -zP "^PROD=0$" .env
Original file line number Diff line number Diff line change 1- # Create .env
1+ # Create a .env
22
33---
4+
5+ This action will create a ` .env ` file in the directory of your choice & with the content of your choice.
6+
7+ ``` yml
8+ - name : Create .env 🤫
9+ uses :
DeveloperRic/[email protected] # set this to the version of your choice 10+ with :
11+ # Write your content here if you want. The content will be trimmed & dedent will be applied.
12+ full_text : |
13+ PROD=1
14+ PORT=3000
15+ API_AUDIENCE=api.mydomain.xyz
16+ # Specify the directory that the .env file should go in.
17+ # This defaults to the current directory (i.e. '.')
18+ directory : ${{ github.workspace }}/server/src
19+ # Set this if you want the action to look in environment variables for extra content. This input is not required.
20+ # Note: setting to false or any other value will still enable environment variable lookup.
21+ # If you don't want this turned on, don't include the input.
22+ include_env_vars : true
23+ env :
24+ # If `include_env_vars` is true, the following environment variables will be written to the .env file as:
25+ # PROD=${{ secrets.PROD }}
26+ # ACTION_CREATE_ENV_JOKE: ${{ secrets.ACTION_CREATE_ENV_JOKE }}
27+ # Note: `full_text` is dumped to the .env file first and subsequently environment variables are dumped.
28+ # This means that duplicate entries may exist in the .env file.
29+ ACTION_CREATE_ENV_PROD : ${{ secrets.PROD }}
30+ ACTION_CREATE_ENV_ACTION_CREATE_ENV_JOKE : ${{ secrets.ACTION_CREATE_ENV_JOKE }}
31+ ` ` `
Original file line number Diff line number Diff line change @@ -85,6 +85,18 @@ test('includes env vars', async () => {
8585 expect ( content ) . toEqual ( `PROD=0\n_${ ENV_PREFIX } _TEST=1` )
8686} )
8787
88+ test ( 'skips env vars when include_env_vars is disabled' , async ( ) => {
89+ const args : Args = {
90+ directory : ARTIFACTS_PATH ,
91+ full_text : 'PROD=0\n' , // should be trimmed
92+ include_env_vars : ! ! ''
93+ }
94+ process . env [ `${ ENV_PREFIX } _TEST` ] = '1'
95+ await writeToEnvFile ( args )
96+ const content = fs . readFileSync ( `${ args . directory } /.env` ) . toString ( )
97+ expect ( content ) . toEqual ( `PROD=0` )
98+ } )
99+
88100// shows how the runner will run a javascript action with env / stdout protocol
89101test ( 'test runs' , ( ) => {
90102 process . env [ 'INPUT_FULL_TEXT' ] = 'PROD=0'
Original file line number Diff line number Diff line change 11name : ' Create a .env file'
22description : ' Create a .env file'
3+ branding :
4+ icon : ' box'
5+ color : ' orange'
36author : ' https://github.com/DeveloperRic'
47inputs :
58 full_text :
You can’t perform that action at this time.
0 commit comments