cufflink-cli 0.10.1

CLI for the Cufflink CRUD microservice platform — deploy, init, and manage services
name: Cufflink Deploy

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: wasm32-unknown-unknown

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: ${{ runner.os }}-cargo-

      - name: Run unit tests
        run: cargo test

  deploy-staging:
    name: Deploy to Staging
    needs: test
    if: github.ref == 'refs/heads/main' && github.event_name == 'push'
    runs-on: ubuntu-latest
    environment: staging
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: wasm32-unknown-unknown

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: ${{ runner.os }}-cargo-

      - name: Install Cufflink CLI
        run: cargo install cufflink-cli

      - name: Deploy to staging
        env:
          CUFFLINK_STAGING_API_KEY: ${{ secrets.CUFFLINK_STAGING_API_KEY }}
        run: cufflink deploy --env staging

  integration-test:
    name: Integration Tests
    needs: deploy-staging
    runs-on: ubuntu-latest
    environment: staging
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: ${{ runner.os }}-cargo-

      - name: Install Cufflink CLI
        run: cargo install cufflink-cli

      - name: Run integration tests
        env:
          CUFFLINK_STAGING_API_KEY: ${{ secrets.CUFFLINK_STAGING_API_KEY }}
        run: cufflink test --env staging

  deploy-production:
    name: Deploy to Production
    needs: integration-test
    runs-on: ubuntu-latest
    environment: production
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: wasm32-unknown-unknown

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: ${{ runner.os }}-cargo-

      - name: Install Cufflink CLI
        run: cargo install cufflink-cli

      - name: Deploy to production
        env:
          CUFFLINK_PROD_API_KEY: ${{ secrets.CUFFLINK_PROD_API_KEY }}
        run: cufflink deploy --env production