fix: refactor PR Validation workflow to use Replicated actions #121
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| 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: ${{ vars.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 preserves original case for resource naming (clusters, customers) | |
| BRANCH_NAME="${{ github.head_ref || github.ref_name }}" | |
| # Channel name is normalized to lowercase with hyphens for Replicated channels | |
| CHANNEL_NAME=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]' | tr '/' '-') | |
| echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
| echo "channel-name=$CHANNEL_NAME" >> $GITHUB_OUTPUT | |
| echo "Branch: $BRANCH_NAME, Channel: $CHANNEL_NAME" | |
| validate-charts: | |
| runs-on: ubuntu-22.04 | |
| needs: setup | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Validate charts | |
| uses: ./.github/actions/chart-validate | |
| with: | |
| app-dir: ${{ env.APP_DIR }} | |
| helm-version: ${{ env.HELM_VERSION }} | |
| - name: Validate Taskfile syntax | |
| run: task --list-all | |
| working-directory: ${{ env.APP_DIR }} | |
| build-and-package: | |
| runs-on: ubuntu-22.04 | |
| needs: [setup, validate-charts] | |
| outputs: | |
| release-path: ${{ steps.package.outputs.release-path }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Package charts | |
| id: package | |
| uses: ./.github/actions/chart-package | |
| with: | |
| app-dir: ${{ env.APP_DIR }} | |
| helm-version: ${{ env.HELM_VERSION }} | |
| - name: Upload release artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wg-easy-release-${{ github.run_number }} | |
| path: ${{ steps.package.outputs.release-path }} | |
| retention-days: 7 | |
| create-release: | |
| runs-on: ubuntu-22.04 | |
| needs: [setup, build-and-package] | |
| outputs: | |
| channel-slug: ${{ steps.release.outputs.channel-slug }} | |
| release-sequence: ${{ steps.release.outputs.release-sequence }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download release artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wg-easy-release-${{ github.run_number }} | |
| path: ${{ env.APP_DIR }}/release | |
| - name: Create Replicated release | |
| id: release | |
| uses: replicatedhq/replicated-actions/[email protected] | |
| with: | |
| app-slug: ${{ env.REPLICATED_APP }} | |
| api-token: ${{ env.REPLICATED_API_TOKEN }} | |
| yaml-dir: ${{ env.APP_DIR }}/release | |
| promote-channel: ${{ needs.setup.outputs.channel-name }} | |
| test-deployment: | |
| runs-on: ubuntu-22.04 | |
| needs: [setup, create-release] | |
| outputs: | |
| customer-id: ${{ steps.create-customer.outputs.customer-id }} | |
| license-id: ${{ steps.create-customer.outputs.license-id }} | |
| cluster-id: ${{ steps.create-cluster.outputs.cluster-id }} | |
| 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: Create customer | |
| id: create-customer | |
| uses: replicatedhq/replicated-actions/[email protected] | |
| with: | |
| app-slug: ${{ env.REPLICATED_APP }} | |
| api-token: ${{ env.REPLICATED_API_TOKEN }} | |
| customer-name: ${{ needs.setup.outputs.channel-name }} | |
| channel-slug: ${{ needs.create-release.outputs.channel-slug }} | |
| license-type: dev | |
| - name: Create cluster | |
| id: create-cluster | |
| uses: replicatedhq/replicated-actions/[email protected] | |
| with: | |
| api-token: ${{ env.REPLICATED_API_TOKEN }} | |
| kubernetes-distribution: k3s | |
| kubernetes-version: v1.32.2 | |
| cluster-name: ${{ needs.setup.outputs.channel-name }} | |
| ttl: 4h | |
| nodes: 1 | |
| instance-type: r1.small | |
| export-kubeconfig: 'true' | |
| - name: Setup cluster ports | |
| working-directory: ${{ env.APP_DIR }} | |
| run: | | |
| task cluster-ports-expose CLUSTER_NAME="${{ needs.setup.outputs.channel-name }}" | |
| - name: Deploy application | |
| working-directory: ${{ env.APP_DIR }} | |
| run: | | |
| task customer-helm-install \ | |
| CUSTOMER_NAME="${{ needs.setup.outputs.channel-name }}" \ | |
| CLUSTER_NAME="${{ needs.setup.outputs.channel-name }}" \ | |
| CHANNEL_SLUG="${{ needs.create-release.outputs.channel-slug }}" \ | |
| REPLICATED_LICENSE_ID="${{ steps.create-customer.outputs.license-id }}" | |
| timeout-minutes: 20 | |
| - name: Run tests | |
| working-directory: ${{ env.APP_DIR }} | |
| run: task test | |
| timeout-minutes: 10 | |
| - name: Upload debug logs | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: debug-logs-${{ github.run_number }} | |
| path: | | |
| /tmp/*.log | |
| ~/.replicated/ |