|
| 1 | +name: Local Actions Example |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main, develop] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + # Run evaluations using local action |
| 11 | + run-evaluations: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@v4 |
| 19 | + with: |
| 20 | + python-version: '3.11' |
| 21 | + |
| 22 | + - name: Install dependencies |
| 23 | + run: | |
| 24 | + pip install pytest langsmith openevals anthropic |
| 25 | + pip install -e . |
| 26 | +
|
| 27 | + # Use local LangSmith Evaluation Action |
| 28 | + - name: Run LangSmith Evaluations |
| 29 | + uses: ./langsmith-eval-action |
| 30 | + with: |
| 31 | + action: 'run-evaluations' |
| 32 | + langsmith-api-key: ${{ secrets.LANGSMITH_API_KEY }} |
| 33 | + test-command: 'pytest tests/offline_evals/ -m evaluator --verbose' |
| 34 | + max-concurrency: '5' |
| 35 | + fail-on-threshold: 'true' |
| 36 | + environment-variables: | |
| 37 | + { |
| 38 | + "OPENAI_API_KEY": "${{ secrets.OPENAI_API_KEY }}", |
| 39 | + "ANTHROPIC_API_KEY": "${{ secrets.ANTHROPIC_API_KEY }}", |
| 40 | + "EVALUATION_MODE": "comprehensive" |
| 41 | + } |
| 42 | + env: |
| 43 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + |
| 45 | + # Build Docker image for deployments |
| 46 | + build: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + if: github.event.action != 'closed' |
| 49 | + outputs: |
| 50 | + image-uri: ${{ steps.build.outputs.image-uri }} |
| 51 | + steps: |
| 52 | + - name: Checkout |
| 53 | + uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - name: Build Docker image |
| 56 | + id: build |
| 57 | + run: | |
| 58 | + IMAGE_URI="docker.io/text2sql/app:${{ github.sha }}" |
| 59 | + echo "Building image: $IMAGE_URI" |
| 60 | + # docker build -t $IMAGE_URI . |
| 61 | + # docker push $IMAGE_URI |
| 62 | + echo "image-uri=$IMAGE_URI" >> $GITHUB_OUTPUT |
| 63 | +
|
| 64 | + # Deploy preview environment using local action |
| 65 | + deploy-preview: |
| 66 | + needs: [run-evaluations, build] |
| 67 | + runs-on: ubuntu-latest |
| 68 | + if: github.event_name == 'pull_request' && github.event.action != 'closed' |
| 69 | + steps: |
| 70 | + - name: Checkout |
| 71 | + uses: actions/checkout@v4 |
| 72 | + |
| 73 | + # Use local LangGraph Deploy Action |
| 74 | + - name: Deploy Preview Environment |
| 75 | + uses: ./langgraph-deploy-action |
| 76 | + with: |
| 77 | + action: 'deploy-preview' |
| 78 | + api-key: ${{ secrets.LANGSMITH_API_KEY }} |
| 79 | + image-uri: ${{ needs.build.outputs.image-uri }} |
| 80 | + pr-number: ${{ github.event.pull_request.number }} |
| 81 | + app-name: 'text2sql-agent' |
| 82 | + secrets: | |
| 83 | + { |
| 84 | + "OPENAI_API_KEY": "${{ secrets.OPENAI_API_KEY }}", |
| 85 | + "ANTHROPIC_API_KEY": "${{ secrets.ANTHROPIC_API_KEY }}" |
| 86 | + } |
| 87 | + resource-cpu: '2' |
| 88 | + resource-memory: '2048' |
| 89 | + min-scale: '1' |
| 90 | + max-scale: '3' |
| 91 | + |
| 92 | + # Deploy to production using local action |
| 93 | + deploy-production: |
| 94 | + needs: [run-evaluations, build] |
| 95 | + runs-on: ubuntu-latest |
| 96 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
| 97 | + environment: production |
| 98 | + steps: |
| 99 | + - name: Checkout |
| 100 | + uses: actions/checkout@v4 |
| 101 | + |
| 102 | + # Use local LangGraph Deploy Action |
| 103 | + - name: Deploy to Production |
| 104 | + uses: ./langgraph-deploy-action |
| 105 | + with: |
| 106 | + action: 'deploy-production' |
| 107 | + api-key: ${{ secrets.LANGSMITH_API_KEY }} |
| 108 | + image-uri: ${{ needs.build.outputs.image-uri }} |
| 109 | + deployment-name: 'text2sql-agent-prod' |
| 110 | + secrets: | |
| 111 | + { |
| 112 | + "OPENAI_API_KEY": "${{ secrets.OPENAI_API_KEY }}", |
| 113 | + "ANTHROPIC_API_KEY": "${{ secrets.ANTHROPIC_API_KEY }}", |
| 114 | + "DATABASE_URL": "${{ secrets.PROD_DATABASE_URL }}", |
| 115 | + "ENVIRONMENT": "production" |
| 116 | + } |
| 117 | + resource-cpu: '4' |
| 118 | + resource-memory: '4096' |
| 119 | + min-scale: '2' |
| 120 | + max-scale: '10' |
| 121 | + |
| 122 | + # Cleanup preview when PR is closed |
| 123 | + cleanup-preview: |
| 124 | + runs-on: ubuntu-latest |
| 125 | + if: github.event_name == 'pull_request' && github.event.action == 'closed' |
| 126 | + steps: |
| 127 | + - name: Checkout |
| 128 | + uses: actions/checkout@v4 |
| 129 | + |
| 130 | + # Use local LangGraph Deploy Action |
| 131 | + - name: Cleanup Preview Environment |
| 132 | + uses: ./langgraph-deploy-action |
| 133 | + with: |
| 134 | + action: 'cleanup-preview' |
| 135 | + api-key: ${{ secrets.LANGSMITH_API_KEY }} |
| 136 | + pr-number: ${{ github.event.pull_request.number }} |
| 137 | + app-name: 'text2sql-agent' |
0 commit comments