3.4 KiB
3.4 KiB
🛠️ Prepare Deployment File Action
Automatically process your Docker Compose or Stack deployment files by substituting placeholders with values from GitHub Action inputs, environment variables, and secrets. 🚀
✨ Features
- 📄 Flexible file processing: Supports Docker Compose and Stack files.
- 🔄 Dynamic substitutions: Replace placeholders with inputs, environment variables, and secrets.
- 📋 Detailed debug logs: Clearly see each substitution step for easy troubleshooting.
- 📦 Outputs processed file: Ready-to-use deployment file for seamless deployments.
📥 Inputs
| Input | Description | Required |
|---|---|---|
compose_file |
Deployment file to process (e.g., docker-compose.yml) |
✅ Yes |
stack_name |
Stack name to substitute in deployment file | ✅ Yes |
org_name |
Organization name to substitute in deployment file | ✅ Yes |
repo_name |
Repository name to substitute in deployment file | ✅ Yes |
git_sha |
Git short SHA to substitute in deployment file | ✅ Yes |
📤 Outputs
| Output | Description | Example |
|---|---|---|
processed_file |
Path to the processed deployment file | docker-compose.processed.yml |
🛠️ Example Usage
Here's how you can integrate this action into your workflow:
- name: Prepare Deployment File 🛠️
id: prepare-deploy
uses: your-org/prepare-deployment-file@main
with:
compose_file: docker-compose.yml
stack_name: my-awesome-stack
org_name: my-org
repo_name: my-repo
git_sha: ${{ github.sha }}
- name: Deploy 🚀
run: |
echo "Deploying using processed file: ${{ steps.prepare-deploy.outputs.processed_file }}"
🧑💻 How It Works
This action performs the following steps:
| Step | Description |
|---|---|
| 📄 | Copies your original deployment file to a new processed file |
| 🔄 | Substitutes placeholders with values from .env file (if present) |
| 🔄 | Substitutes placeholders with GitHub Action inputs (stack_name, org_name, repo_name, git_sha) |
| 🔄 | Substitutes placeholders with environment variables and secrets available in GitHub Actions |
| 📋 | Provides detailed debug logs of each substitution step |
| 📦 | Outputs the path to the processed deployment file |
📖 Debugging & Logs
Detailed debug logs are provided at every substitution step, making troubleshooting easy:
DEBUG: Processing deployment file: docker-compose.yml
DEBUG: Found .env file. Substituting variables from .env.
DEBUG: Replacing ${MY_ENV_VAR} with value from .env
DEBUG: Replacing ${STACK_NAME} with GitHub Action input value 'my-stack'
...
DEBUG: Final processed deployment file path:
docker-compose.processed.yml
⚠️ Requirements
- Your deployment file should contain placeholders in the format
${PLACEHOLDER_NAME}. - Optional
.envfile at the repository root for additional substitutions.
📜 License
This action is open-source software licensed under the MIT license.
Happy deploying! 🎉
— Grand