Skip to content

start gh actions workflows #28

start gh actions workflows

start gh actions workflows #28

---
name: WG-Easy PR Validation - build, release, install
on:
pull_request:
branches: [main]
paths:
- 'applications/wg-easy/**'
- '.github/workflows/wg-easy-pr-validation.yaml'
workflow_dispatch:
inputs:
test_mode:
description: 'Run in test mode'
required: false
default: 'true'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
APP_DIR: applications/wg-easy
REPLICATED_API_TOKEN: ${{ secrets.WG_EASY_REPLICATED_API_TOKEN }}
REPLICATED_APP: ${{ secrets.WG_EASY_REPLICATED_APP }}
HELM_VERSION: "3.17.3"
KUBECTL_VERSION: "v1.30.0"
jobs:
setup:
runs-on: ubuntu-22.04
outputs:
branch-name: ${{ steps.vars.outputs.branch-name }}
channel-name: ${{ steps.vars.outputs.channel-name }}
steps:
- name: Set branch and channel variables
id: vars
run: |
BRANCH_NAME="${{ github.head_ref || github.ref_name }}"
CHANNEL_NAME=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]')
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
echo "channel-name=$CHANNEL_NAME" >> $GITHUB_OUTPUT
echo "Branch: $BRANCH_NAME, Channel: $CHANNEL_NAME"
build-release:
runs-on: ubuntu-22.04
needs: setup
defaults:
run:
working-directory: ${{ env.APP_DIR }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Helm dependencies
uses: actions/cache@v4
with:
path: |
applications/wg-easy/charts/*/charts
applications/wg-easy/Chart.lock
key: helm-deps-${{ hashFiles('applications/wg-easy/charts/*/Chart.yaml') }}
- name: Setup tools
uses: ./.github/actions/setup-tools
with:
helm-version: ${{ env.HELM_VERSION }}
kubectl-version: ${{ env.KUBECTL_VERSION }}
install-kubectl: 'true'
install-preflight: 'true'
- name: Update dependencies
run: task dependencies-update
timeout-minutes: 10
- name: Prepare release
run: task release-prepare
timeout-minutes: 10
- name: Verify release directory contents
run: |
echo "Checking release directory contents:"
ls -la release/
echo "Verifying required files exist:"
test -f release/application.yaml
test -f release/config.yaml
test -f release/cluster.yaml
find release/ -name "*.tgz" | wc -l | grep -v "^0$"
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: wg-easy-release-${{ github.run_number }}
path: ${{ env.APP_DIR }}/release/
retention-days: 7
lint-and-validate:
runs-on: ubuntu-22.04
needs: setup
defaults:
run:
working-directory: ${{ env.APP_DIR }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Helm dependencies
uses: actions/cache@v4
with:
path: |
applications/wg-easy/charts/*/charts
applications/wg-easy/Chart.lock
key: helm-deps-${{ hashFiles('applications/wg-easy/charts/*/Chart.yaml') }}
- name: Setup tools
uses: ./.github/actions/setup-tools
with:
helm-version: ${{ env.HELM_VERSION }}
- name: Update dependencies
run: task dependencies-update
- name: Lint Helm charts
run: |
for chart_dir in $(find charts/ -maxdepth 2 -name "Chart.yaml" | \
xargs dirname); do
echo "Linting chart: $chart_dir"
helm lint "$chart_dir"
done
- name: Template Helm charts
run: |
for chart_dir in $(find charts/ -maxdepth 2 -name "Chart.yaml" | \
xargs dirname); do
echo "Templating chart: $chart_dir"
helm template test-release "$chart_dir" --dry-run
done
- name: Validate Taskfile syntax
run: task --list-all
- name: Validate helmfile template
uses: helmfile/[email protected]
if: hashFiles('helmfile.yaml.gotmpl') != ''
with:
helmfile-args: build
helmfile-workdirectory: ${{ env.APP_DIR }}
env:
REPLICATED_APP: "test-app"
CHANNEL: "unstable"
REPLICATED_LICENSE_ID: "test-license"
TF_EXPOSED_URL: "test.example.com"
replicated-release:
runs-on: ubuntu-22.04
needs: [setup, build-release]
defaults:
run:
working-directory: ${{ env.APP_DIR }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup tools
uses: ./.github/actions/setup-tools
with:
helm-version: ${{ env.HELM_VERSION }}
kubectl-version: ${{ env.KUBECTL_VERSION }}
install-kubectl: 'true'
- name: Create channel for branch
run: task channel-create RELEASE_CHANNEL="${{ needs.setup.outputs.channel-name }}"
timeout-minutes: 5
- name: Prepare release
run: task release-prepare
timeout-minutes: 15
- name: Create release
run: task release-create RELEASE_CHANNEL="${{ needs.setup.outputs.channel-name }}"
timeout-minutes: 15
create-customer-and-cluster:
runs-on: ubuntu-22.04
needs: [setup, replicated-release]
defaults:
run:
working-directory: ${{ env.APP_DIR }}
outputs:
license-id: ${{ steps.license.outputs.license-id }}
skip-customer-registry: ${{ steps.prereqs.outputs.skip-customer-registry }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check prerequisites
id: prereqs
run: |
if [ -z "${{ secrets.WG_EASY_CUSTOMER_EMAIL }}" ]; then
echo "::warning::WG_EASY_CUSTOMER_EMAIL secret not found - skipping customer registry login"
echo "skip-customer-registry=true" >> $GITHUB_OUTPUT
else
echo "skip-customer-registry=false" >> $GITHUB_OUTPUT
fi
- name: Setup tools
uses: ./.github/actions/setup-tools
- name: Create customer
if: steps.prereqs.outputs.skip-customer-registry == 'false'
run: task customer-create CUSTOMER_NAME="${{ needs.setup.outputs.branch-name }}" RELEASE_CHANNEL="${{ needs.setup.outputs.channel-name }}"
timeout-minutes: 5
- name: Create cluster with retry
uses: nick-fields/[email protected]
with:
timeout_minutes: 20
retry_wait_seconds: 30
max_attempts: 3
command: |
cd ${{ env.APP_DIR }}
task cluster-create CLUSTER_NAME="${{ needs.setup.outputs.branch-name }}"
- name: Get customer license ID
if: steps.prereqs.outputs.skip-customer-registry == 'false'
id: license
run: |
LICENSE_ID=$(task utils:get-customer-license CUSTOMER_NAME="${{ needs.setup.outputs.branch-name }}" --silent | tail -1)
echo "license-id=$LICENSE_ID" >> $GITHUB_OUTPUT
echo "::add-mask::$LICENSE_ID"
helm-install-test:
runs-on: ubuntu-22.04
needs: [setup, create-customer-and-cluster]
defaults:
run:
working-directory: ${{ env.APP_DIR }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup tools
uses: ./.github/actions/setup-tools
with:
helm-version: ${{ env.HELM_VERSION }}
install-helmfile: 'true'
- name: Update dependencies
run: task dependencies-update
- name: Helm registry login
if: needs.create-customer-and-cluster.outputs.skip-customer-registry == 'false'
run: |
helm registry login registry.replicated.com --username "${{ secrets.WG_EASY_CUSTOMER_EMAIL }}" --password "${{ needs.create-customer-and-cluster.outputs.license-id }}"
timeout-minutes: 5
- name: Helm install
run: task helm-install
timeout-minutes: 20
env:
CHANNEL: ${{ needs.setup.outputs.channel-name }}
REPLICATED_LICENSE_ID: ${{ needs.create-customer-and-cluster.outputs.license-id || 'test-license' }}
HELM_ENV: ${{ needs.create-customer-and-cluster.outputs.skip-customer-registry == 'true' && 'default' || 'replicated' }}
- name: Upload debug logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: debug-logs-${{ github.run_number }}
path: |
/tmp/*.log
~/.replicated/