Skip to content

Commit fd3132f

Browse files
adamanciniclaudehedge-sparrow
authored
start gh actions workflows (#69)
Co-authored-by: Claude <[email protected]> Co-authored-by: hedge-sparrow <[email protected]>
1 parent f7aa83e commit fd3132f

File tree

25 files changed

+2353
-104
lines changed

25 files changed

+2353
-104
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 'Package Helm Charts'
2+
description: 'Package all Helm charts and prepare release artifacts'
3+
inputs:
4+
app-dir:
5+
description: 'Application directory containing charts'
6+
default: 'applications/wg-easy'
7+
helm-version:
8+
description: 'Helm version to use'
9+
default: '3.17.3'
10+
use-cache:
11+
description: 'Whether to use dependency cache'
12+
default: 'true'
13+
outputs:
14+
release-path:
15+
description: 'Path to release artifacts'
16+
value: ${{ inputs.app-dir }}/release
17+
18+
runs:
19+
using: 'composite'
20+
steps:
21+
- name: Setup tools
22+
uses: ./.github/actions/setup-tools
23+
with:
24+
helm-version: ${{ inputs.helm-version }}
25+
26+
- name: Cache Helm dependencies
27+
if: inputs.use-cache == 'true'
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
${{ inputs.app-dir }}/charts/*/charts
32+
${{ inputs.app-dir }}/Chart.lock
33+
key: helm-deps-${{ hashFiles(format('{0}/charts/*/Chart.yaml', inputs.app-dir)) }}
34+
35+
- name: Package charts
36+
shell: bash
37+
working-directory: ${{ inputs.app-dir }}
38+
run: task chart-package-all
39+
40+
- name: Verify release contents
41+
shell: bash
42+
working-directory: ${{ inputs.app-dir }}
43+
run: |
44+
echo "Verifying release directory contents:"
45+
ls -la release/
46+
echo "Checking required files:"
47+
test -f release/application.yaml
48+
test -f release/config.yaml
49+
test -f release/cluster.yaml
50+
echo "Chart packages:"
51+
find release/ -name "*.tgz" | wc -l | grep -v "^0$"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 'Validate Helm Charts'
2+
description: 'Validate all Helm charts using Task-based operations'
3+
inputs:
4+
app-dir:
5+
description: 'Application directory containing charts'
6+
default: 'applications/wg-easy'
7+
helm-version:
8+
description: 'Helm version to use'
9+
default: '3.17.3'
10+
use-cache:
11+
description: 'Whether to use dependency cache'
12+
default: 'true'
13+
14+
runs:
15+
using: 'composite'
16+
steps:
17+
- name: Setup tools
18+
uses: ./.github/actions/setup-tools
19+
with:
20+
helm-version: ${{ inputs.helm-version }}
21+
install-helmfile: 'true'
22+
23+
- name: Cache Helm dependencies
24+
if: inputs.use-cache == 'true'
25+
uses: actions/cache@v4
26+
with:
27+
path: |
28+
${{ inputs.app-dir }}/charts/*/charts
29+
${{ inputs.app-dir }}/Chart.lock
30+
key: helm-deps-${{ hashFiles(format('{0}/charts/*/Chart.yaml', inputs.app-dir)) }}
31+
32+
- name: Validate charts
33+
shell: bash
34+
working-directory: ${{ inputs.app-dir }}
35+
run: task chart-validate
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Create Replicated Release'
2+
description: 'Create channel and release using Task-based operations'
3+
inputs:
4+
app-dir:
5+
description: 'Application directory containing charts'
6+
default: 'applications/wg-easy'
7+
channel-name:
8+
description: 'Release channel name'
9+
required: true
10+
channel-id:
11+
description: 'Release channel ID (optional, takes precedence over channel-name)'
12+
required: false
13+
release-version:
14+
description: 'Release version'
15+
default: '0.0.1'
16+
release-notes:
17+
description: 'Release notes'
18+
default: 'Release created via GitHub Actions'
19+
20+
outputs:
21+
channel-id:
22+
description: 'Channel ID created or found'
23+
value: ${{ steps.channel.outputs.channel-id }}
24+
25+
runs:
26+
using: 'composite'
27+
steps:
28+
- name: Setup tools
29+
uses: ./.github/actions/setup-tools
30+
31+
- name: Create channel
32+
id: channel
33+
shell: bash
34+
working-directory: ${{ inputs.app-dir }}
35+
run: |
36+
CHANNEL_ID=$(task channel-create RELEASE_CHANNEL="${{ inputs.channel-name }}" --silent | tail -1)
37+
echo "channel-id=$CHANNEL_ID" >> $GITHUB_OUTPUT
38+
echo "Created/found channel with ID: $CHANNEL_ID"
39+
40+
- name: Create release
41+
shell: bash
42+
working-directory: ${{ inputs.app-dir }}
43+
run: |
44+
task release-create \
45+
RELEASE_CHANNEL_ID="${{ steps.channel.outputs.channel-id }}" \
46+
RELEASE_CHANNEL="${{ inputs.channel-name }}" \
47+
RELEASE_VERSION="${{ inputs.release-version }}" \
48+
RELEASE_NOTES="${{ inputs.release-notes }}"
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: 'Setup Common Tools'
2+
description: 'Setup Helm, Task, yq, kubectl, preflight, helmfile, and Replicated CLI'
3+
inputs:
4+
helm-version:
5+
description: 'Helm version'
6+
default: '3.17.3'
7+
kubectl-version:
8+
description: 'kubectl version'
9+
default: 'v1.30.0'
10+
app-dir:
11+
description: 'Application directory'
12+
default: 'applications/wg-easy'
13+
install-kubectl:
14+
description: 'Whether to install kubectl'
15+
default: 'false'
16+
install-preflight:
17+
description: 'Whether to install preflight'
18+
default: 'false'
19+
install-helmfile:
20+
description: 'Whether to install helmfile'
21+
default: 'false'
22+
23+
runs:
24+
using: 'composite'
25+
steps:
26+
- name: Setup Helm
27+
uses: azure/setup-helm@v4
28+
with:
29+
version: ${{ inputs.helm-version }}
30+
31+
- name: Setup Task
32+
uses: arduino/setup-task@v2
33+
with:
34+
version: 3.x
35+
repo-token: ${{ github.token }}
36+
37+
- name: Setup kubectl
38+
if: inputs.install-kubectl == 'true'
39+
uses: azure/setup-kubectl@v4
40+
with:
41+
version: ${{ inputs.kubectl-version }}
42+
43+
- name: Cache tools
44+
uses: actions/cache@v4
45+
with:
46+
path: |
47+
/usr/local/bin/yq
48+
/usr/local/bin/preflight
49+
/usr/local/bin/helmfile
50+
~/.replicated
51+
key: tools-${{ runner.os }}-yq-v4.44.3-preflight-v0.95.0-helmfile-v0.170.0-replicated-${{ hashFiles('**/taskfiles/utils.yml') }}
52+
restore-keys: |
53+
tools-${{ runner.os }}-yq-v4.44.3-preflight-v0.95.0-helmfile-v0.170.0-
54+
55+
- name: Install yq
56+
shell: bash
57+
run: |
58+
if [ ! -f /usr/local/bin/yq ]; then
59+
echo "Installing yq v4.44.3..."
60+
sudo wget https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64 -O /usr/local/bin/yq
61+
sudo chmod +x /usr/local/bin/yq
62+
else
63+
echo "yq already installed (cached)"
64+
fi
65+
66+
- name: Install preflight CLI
67+
if: inputs.install-preflight == 'true'
68+
shell: bash
69+
run: |
70+
if [ ! -f /usr/local/bin/preflight ]; then
71+
echo "Installing preflight v0.95.0..."
72+
curl -L https://github.com/replicatedhq/troubleshoot/releases/download/v0.95.0/preflight_linux_amd64.tar.gz | tar xz
73+
sudo mv preflight /usr/local/bin/
74+
else
75+
echo "preflight already installed (cached)"
76+
fi
77+
78+
- name: Install helmfile
79+
if: inputs.install-helmfile == 'true'
80+
shell: bash
81+
run: |
82+
if [ ! -f /usr/local/bin/helmfile ]; then
83+
echo "Installing helmfile v0.170.0..."
84+
curl -L https://github.com/helmfile/helmfile/releases/download/v0.170.0/helmfile_0.170.0_linux_amd64.tar.gz | tar xz
85+
sudo mv helmfile /usr/local/bin/
86+
sudo chmod +x /usr/local/bin/helmfile
87+
else
88+
echo "helmfile already installed (cached)"
89+
fi
90+
91+
- name: Install Replicated CLI
92+
shell: bash
93+
working-directory: ${{ inputs.app-dir }}
94+
run: task utils:install-replicated-cli
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: 'Test Deployment'
2+
description: 'Test deployment using customer workflow'
3+
inputs:
4+
app-dir:
5+
description: 'Application directory containing charts'
6+
default: 'applications/wg-easy'
7+
customer-name:
8+
description: 'Customer name for testing'
9+
required: true
10+
cluster-name:
11+
description: 'Cluster name for testing'
12+
required: true
13+
channel-name:
14+
description: 'Channel name for testing'
15+
required: false
16+
channel-id:
17+
description: 'Channel ID for testing (optional, takes precedence over channel-name)'
18+
required: false
19+
helm-version:
20+
description: 'Helm version to use'
21+
default: '3.17.3'
22+
cleanup:
23+
description: 'Whether to cleanup resources after testing'
24+
default: 'false'
25+
26+
outputs:
27+
customer-license:
28+
description: 'Customer license ID used for testing'
29+
value: ${{ steps.license.outputs.license-id }}
30+
31+
runs:
32+
using: 'composite'
33+
steps:
34+
- name: Setup tools
35+
uses: ./.github/actions/setup-tools
36+
with:
37+
helm-version: ${{ inputs.helm-version }}
38+
install-helmfile: 'true'
39+
40+
- name: Create customer
41+
shell: bash
42+
working-directory: ${{ inputs.app-dir }}
43+
run: |
44+
if [ -n "${{ inputs.channel-id }}" ]; then
45+
task customer-create \
46+
CUSTOMER_NAME="${{ inputs.customer-name }}" \
47+
RELEASE_CHANNEL_ID="${{ inputs.channel-id }}"
48+
else
49+
task customer-create \
50+
CUSTOMER_NAME="${{ inputs.customer-name }}" \
51+
RELEASE_CHANNEL="${{ inputs.channel-name }}"
52+
fi
53+
54+
- name: Get customer license
55+
id: license
56+
shell: bash
57+
working-directory: ${{ inputs.app-dir }}
58+
run: |
59+
LICENSE_ID=$(task utils:get-customer-license CUSTOMER_NAME="${{ inputs.customer-name }}" --silent | tail -1)
60+
echo "license-id=$LICENSE_ID" >> $GITHUB_OUTPUT
61+
echo "::add-mask::$LICENSE_ID"
62+
63+
- name: Create cluster with retry
64+
uses: nick-fields/[email protected]
65+
with:
66+
timeout_minutes: 20
67+
retry_wait_seconds: 30
68+
max_attempts: 3
69+
command: |
70+
cd ${{ inputs.app-dir }}
71+
task cluster-create CLUSTER_NAME="${{ inputs.cluster-name }}"
72+
73+
- name: Setup cluster
74+
shell: bash
75+
working-directory: ${{ inputs.app-dir }}
76+
run: |
77+
task setup-kubeconfig CLUSTER_NAME="${{ inputs.cluster-name }}"
78+
task cluster-ports-expose CLUSTER_NAME="${{ inputs.cluster-name }}"
79+
80+
- name: Deploy application
81+
shell: bash
82+
working-directory: ${{ inputs.app-dir }}
83+
run: |
84+
if [ -n "${{ inputs.channel-id }}" ]; then
85+
task customer-helm-install \
86+
CUSTOMER_NAME="${{ inputs.customer-name }}" \
87+
CLUSTER_NAME="${{ inputs.cluster-name }}" \
88+
CHANNEL_ID="${{ inputs.channel-id }}" \
89+
REPLICATED_LICENSE_ID="${{ steps.license.outputs.license-id }}"
90+
else
91+
task customer-helm-install \
92+
CUSTOMER_NAME="${{ inputs.customer-name }}" \
93+
CLUSTER_NAME="${{ inputs.cluster-name }}" \
94+
CHANNEL_SLUG="${{ inputs.channel-name }}" \
95+
REPLICATED_LICENSE_ID="${{ steps.license.outputs.license-id }}"
96+
fi
97+
98+
- name: Run tests
99+
shell: bash
100+
working-directory: ${{ inputs.app-dir }}
101+
run: task test
102+
103+
# - name: Cleanup resources
104+
# if: inputs.cleanup == 'true'
105+
# shell: bash
106+
# working-directory: ${{ inputs.app-dir }}
107+
# run: |
108+
# task cleanup-pr-resources BRANCH_NAME="${{ inputs.customer-name }}"

0 commit comments

Comments
 (0)