Add test_add_negative_keywords #221
Workflow file for this run
This file contains 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: Pipeline | |
on: [push, workflow_dispatch] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
PORT: ${{ vars.PORT }} | |
DOMAIN: ${{ vars.DOMAIN }} | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} | |
jobs: | |
static_analysis: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install Dependencies and library | |
shell: bash | |
run: | | |
set -ux | |
python -m pip install --upgrade pip | |
pip install -e ".[dev]" | |
- name: Run mypy | |
shell: bash | |
run: mypy captn google_ads openai_agent application.py | |
- name: Run bandit | |
shell: bash | |
run: bandit -c pyproject.toml -r captn | |
- name: Run Semgrep | |
shell: bash | |
run: semgrep scan --config auto --error | |
docker_build_push: | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install wasp | |
run: curl -sSL https://get.wasp-lang.dev/installer.sh | sh | |
- name: Log in to the Container registry | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- run: docker pull ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME || docker pull ghcr.io/$GITHUB_REPOSITORY || true | |
- run: docker build --build-arg PORT=$PORT -t ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME . | |
- name: Add tag latest if branch is main | |
if: github.ref_name == 'main' | |
run: docker tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME ghcr.io/$GITHUB_REPOSITORY:latest | |
- name: Push only if branch name is main | |
if: github.ref_name == 'main' | |
run: docker push ghcr.io/$GITHUB_REPOSITORY --all-tags | |
deploy: | |
runs-on: ubuntu-22.04 | |
defaults: | |
run: | |
shell: bash | |
needs: [static_analysis, docker_build_push] | |
if: github.ref_name == 'main' | |
container: | |
image: python:3.7-stretch | |
env: | |
GITHUB_USERNAME: ${{ github.actor }} | |
GITHUB_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
SSH_KEY: ${{ secrets.SSH_KEY }} | |
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} | |
AZURE_API_VERSION: ${{ secrets.AZURE_API_VERSION }} | |
AZURE_API_ENDPOINT: ${{ secrets.AZURE_API_ENDPOINT }} | |
AZURE_MODEL: ${{ secrets.AZURE_MODEL }} | |
DEVELOPER_TOKEN: ${{ secrets.DEVELOPER_TOKEN }} | |
AZURE_OPENAI_API_KEY_SWEEDEN: ${{ secrets.AZURE_OPENAI_API_KEY_SWEEDEN }} | |
AZURE_OPENAI_API_KEY_CANADA: ${{ secrets.AZURE_OPENAI_API_KEY_CANADA }} | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
LITELLM_MODEL: ${{ secrets.LITELLM_MODEL }} | |
LITELLM_API_BASE: ${{ secrets.LITELLM_API_BASE }} | |
LITELLM_API_KEY: ${{ secrets.LITELLM_API_KEY }} | |
steps: | |
- uses: actions/checkout@v3 # Don't change it to cheackout@v4. V4 is not working with container image. | |
# This is to fix GIT not liking owner of the checkout dir - https://github.com/actions/runner/issues/2033#issuecomment-1204205989 | |
- run: chown -R $(id -u):$(id -g) $PWD | |
- run: echo "TAG=latest" >> $GITHUB_ENV | |
# - run: if [[ $GITHUB_REF_NAME == "main" ]]; then printenv PROD_CONFIG > "$(pwd)/.env" ; else printenv STAGING_CONFIG > "$(pwd)/.env" ; fi; | |
- run: echo "PATH=$PATH:/github/home/.local/bin" >> $GITHUB_ENV | |
- run: 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )' | |
- run: eval $(ssh-agent -s) | |
- run: mkdir -p ~/.ssh | |
- run: chmod 700 ~/.ssh | |
- run: ssh-keyscan "$DOMAIN" >> ~/.ssh/known_hosts | |
- run: chmod 644 ~/.ssh/known_hosts | |
- run: echo "$SSH_KEY" | base64 --decode > key.pem | |
- run: chmod 600 key.pem | |
# - run: if [[ $GITHUB_REF_NAME == "main" ]]; then echo "DOMAIN=api.airt.ai" >> $GITHUB_ENV ; else echo "DOMAIN=api.staging.airt.ai" >> $GITHUB_ENV ; fi; | |
- run: ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$DOMAIN" "docker images" | |
- run: sh scripts/deploy.sh | |
- run: rm key.pem |