Skip to content

Commit 168c5c9

Browse files
authored
feat: autodetect envar (#2)
1 parent 1eb2377 commit 168c5c9

File tree

11 files changed

+897
-220
lines changed

11 files changed

+897
-220
lines changed

.github/workflows/release.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,33 @@ jobs:
2626
with:
2727
go-version: '1.22.x'
2828
- name: Build binaries
29-
run: |
30-
make release
31-
- name: Upload files
29+
run: make release
30+
- name: Upload to temp directory
3231
uses: appleboy/[email protected]
3332
with:
3433
host: ${{ secrets.CPANEL_HOST }}
3534
username: ${{ secrets.CPANEL_USER }}
3635
password: ${{ secrets.CPANEL_PASS }}
3736
port: ${{ secrets.CPANEL_PORT }}
38-
source: "dist/"
39-
target: "/home/${{ secrets.CPANEL_USER }}/subdomains/dl.furiatona.dev/azctl"
40-
- name: Update latest symlink
37+
source: "dist/*"
38+
target: "/home/${{ secrets.CPANEL_USER }}/subdomains/dl.furiatona.dev/temp"
39+
- name: Create version directory and move files
4140
uses: appleboy/[email protected]
4241
with:
4342
host: ${{ secrets.CPANEL_HOST }}
4443
username: ${{ secrets.CPANEL_USER }}
4544
password: ${{ secrets.CPANEL_PASS }}
4645
port: ${{ secrets.CPANEL_PORT }}
4746
script: |
48-
VERSION="${GITHUB_REF#refs/tags/}"
49-
cd /home/${{ secrets.CPANEL_USER }}/subdomains/dl.furiatona.dev/azctl
50-
mkdir -p "${VERSION}"
51-
mv * "${VERSION}/" 2>/dev/null || true
52-
ln -sfn "${VERSION}" latest
53-
echo "✅ Files uploaded to dl.furiatona.dev/azctl/${VERSION}/"
54-
echo "✅ Latest symlink updated to point to ${VERSION}"
47+
VERSION=${{ github.ref_name }}
48+
echo "VERSION=$VERSION"
49+
cd /home/${{ secrets.CPANEL_USER }}/subdomains/dl.${{ secrets.CPANEL_USER }}.dev
50+
rm -rf azctl/$VERSION && mkdir -p azctl/$VERSION
51+
mv temp/dist/azctl_* azctl/$VERSION/
52+
rm -rf temp
5553
- name: Upload release assets
5654
uses: softprops/action-gh-release@v2
5755
env:
5856
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
5957
with:
60-
files: |
61-
dist/*
62-
63-
58+
files: dist/*

README.md

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ A production-ready Go CLI tool that wraps Azure CLI commands for container deplo
99
- **ACI Deployment**: Deploy containers with sidecar support using JSON templates
1010
- **Config Management**: Multi-source configuration with proper precedence
1111
- **Environment Support**: Seamless local development and CI/CD integration
12+
- **CI Environment Detection**: Automatic environment detection and variable mapping
1213
- **Validation**: Clear error messages for missing configuration
1314

1415
## Installation
@@ -19,22 +20,22 @@ Download the latest binary from [dl.furiatona.dev](https://dl.furiatona.dev/azct
1920

2021
```bash
2122
# Linux AMD64
22-
curl -L https://dl.furiatona.dev/azctl/v0.2.0/azctl-linux-amd64 -o azctl
23+
curl -L https://dl.furiatona.dev/azctl/v0.2.0/azctl_linux_amd64 -o azctl
2324
chmod +x azctl
2425
sudo mv azctl /usr/local/bin/
2526

2627
# macOS AMD64
27-
curl -L https://dl.furiatona.dev/azctl/v0.2.0/azctl-darwin-amd64 -o azctl
28+
curl -L https://dl.furiatona.dev/azctl/v0.2.0/azctl_darwin_amd64 -o azctl
2829
chmod +x azctl
2930
sudo mv azctl /usr/local/bin/
3031

3132
# macOS ARM64
32-
curl -L https://dl.furiatona.dev/azctl/v0.2.0/azctl-darwin-arm64 -o azctl
33+
curl -L https://dl.furiatona.dev/azctl/v0.2.0/azctl_darwin_arm64 -o azctl
3334
chmod +x azctl
3435
sudo mv azctl /usr/local/bin/
3536

3637
# Windows AMD64
37-
# Download azctl-windows-amd64.exe from https://dl.furiatona.dev/azctl/v0.2.0/
38+
# Download azctl_windows_amd64.exe from https://dl.furiatona.dev/azctl/v0.2.0/
3839
```
3940

4041
### From Source
@@ -71,39 +72,7 @@ make build
7172

7273
> **📖 Need more detailed setup instructions?** See [SETUP.md](SETUP.md) for comprehensive configuration and deployment guides.
7374
74-
## Configuration
75-
76-
### Precedence Order (highest to lowest)
77-
78-
1. **CLI Flags** - Explicit command-line arguments
79-
2. **Environment Variables** - Shell environment and CI variables
80-
3. **.env File** - Local development only (skipped when `CI=true`)
81-
4. **Azure App Configuration** - Centralized defaults (optional)
82-
83-
### Required Variables
84-
85-
#### ACR Commands
86-
- `REGISTRY` - ACR registry name
87-
- `ACR_RESOURCE_GROUP` - Resource group containing ACR
88-
- `IMAGE_NAME` - Container image name
89-
- `IMAGE_TAG` - Container image tag
90-
91-
#### WebApp Deployment
92-
- `AZURE_RESOURCE_GROUP` - Target resource group
93-
- `REGISTRY` - ACR registry name
94-
- `IMAGE_NAME` - Container image name
95-
- `IMAGE_TAG` - Container image tag
96-
97-
#### ACI Deployment
98-
- `AZURE_RESOURCE_GROUP` - Target resource group
99-
- `CONTAINER_GROUP_NAME` - ACI container group name
100-
- `IMAGE_REGISTRY` - ACR registry name
101-
- `IMAGE_NAME` - Container image name
102-
- `IMAGE_TAG` - Container image tag
103-
- `ACR_USERNAME` - Registry username
104-
- `ACR_PASSWORD` - Registry password
105-
106-
## Usage Examples
75+
## Basic Usage
10776

10877
### Build and Push to ACR
10978

@@ -112,12 +81,15 @@ make build
11281
azctl acr
11382

11483
# Using CLI flags
115-
azctl acr --registry myregistry --image myapp --tag v1.0.0 --resource-group my-rg
84+
azctl acr --registry myregistry --image myapp --tag v1.0.0
11685

11786
# With environment-specific config
11887
azctl acr --env dev
11988
azctl acr --env staging
12089
azctl acr --env production
90+
91+
# In CI - environment auto-detected from branch name
92+
azctl acr # Auto-detects 'staging' from 'staging' branch
12193
```
12294

12395
### Deploy to WebApp
@@ -128,6 +100,9 @@ azctl webapp --env staging --resource-group my-rg
128100

129101
# Deploy with custom WebApp name
130102
azctl webapp --env production --name my-custom-webapp
103+
104+
# In CI - environment auto-detected
105+
azctl webapp --resource-group my-rg # Auto-detects environment
131106
```
132107

133108
### Deploy to ACI
@@ -141,6 +116,9 @@ azctl aci --template ./my-aci-template.json --env production
141116

142117
# Dry run - generate JSON without deploying
143118
azctl aci --dry-run --env staging --resource-group staging-rg
119+
120+
# In CI - environment auto-detected
121+
azctl aci --resource-group my-rg # Auto-detects environment
144122
```
145123

146124
## Development
@@ -159,6 +137,20 @@ make lint
159137
make release
160138
```
161139

140+
```bash
141+
# Run tests
142+
make test
143+
144+
# Build binary
145+
make build
146+
147+
# Lint code
148+
make lint
149+
150+
# Cross-platform release build
151+
make release
152+
```
153+
162154
## Contributing
163155

164156
1. Fork the repository

0 commit comments

Comments
 (0)