A GitHub Action that securely fetches secrets from Phase and generates a .env
file for use in your workflows.
This action automates retrieving secrets from Phase and writing them to a .env
file, making it easy to integrate secure environment variables into your GitHub Actions workflows.
- 🔒 Secure authentication using a Phase Service Token
- 📥 Fetches secrets for a specified Phase environment
- 📝 Writes secrets to a
.env
file for seamless use in subsequent steps - ⚡ Simple setup and integration with GitHub Actions
- A Phase account with configured secrets or your own Self-Hosted one.
- A Phase Service Token with appropriate permissions
Note
Make sure you have Ubuntu-based self-hosted runner, This works on them only !
name: Deploy with Phase Secrets
on:
push:
branches: [ master ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Fetch Phase Secrets and generate .env
uses: anilrajrimal1/phase-secrets-fetch-action@v1.0.5
with:
phase_service_token: ${{ secrets.PHASE_SERVICE_TOKEN }}
phase_app_id: "your-phase-app-id"
phase_env: "your-env"
phase_host: "https://host.url.com" #Only if self-hosted, otherwise leave blank
# Your .env file is now available for other steps
- name: Run your application
run: |
docker compose up -d --build
Input | Description | Required |
---|---|---|
phase_service_token |
Your Phase Service Token | ✅ Yes |
phase_app_id |
The id of your Phase application | ✅ Yes |
phase_env |
The environment (e.g., develop, staging, production) | ✅ Yes |
phase_host |
Phase host URL (only for self-hosted instances) | ❌ No |
output_file |
Path to save the .env file (default: .env ) |
❌ No |
secrets_to_fetch |
Space-separated list of specific secrets to fetch | ❌ No |
Output | Description | Value |
---|---|---|
env_file |
Path to the generated .env file |
.env |
- Store your
PHASE_SERVICE_TOKEN
as a GitHub Secret. - Never hardcode secrets in workflow files.
- The action securely fetches secrets using Phase CLI.
- The action installs the Phase CLI.
- Exports necessary environment variables for authentication.
- Fetches all secrets for the given application and environment.
- Writes them to a
.env
file.
- GitHub Actions runner with bash support
Contributions are welcome! Feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Anil Raj Rimal
- Phase for providing a robust secrets management platform.