Simple utility to handle creating and deleting the .env file for a GitHub Actions workflow.
The .env file will be available to subsequent steps in the workflow, and then (optionally) deleted at the end of the job with shred.
Helps with remote development, for example, using VS Code and ngrok-ssh.
name: handle-env
on:
workflow_dispatch:
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: tmshkr/[email protected]
with:
env: |
FOO_VAR=42
BAR_VAR=43
BAZ_VAR=44
SECRET_VAR=${{ secrets.SECRET_VAR }}
- name: Print .env file
run: cat .env
Before the action deletes the .env file, it will look for a .wait
file in the $GITHUB_WORKSPACE
directory.
If the .wait
file exists, the action will wait for that file to be deleted before deleting the .env file.
This can be useful when debugging a workflow, so that you can use or inspect the .env file before it is deleted.