diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 72f3663..98ae9f1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -6,6 +6,13 @@ permissions: id-token: write contents: read +env: + VT_ENV: staging + VT_SITE: staging.cloud.vertesia.io + VT_ACCOUNT: 652d77895674c387e105948c # Dengen Labs + VT_PROJECT: 654df9de09676ad3b8631dc3 # Experiments + VT_PROFILE: staging-experiments # note: this should match the field ".vertesia.profile" in the agent's "package.json" file. + jobs: test: runs-on: ubuntu-latest @@ -42,47 +49,58 @@ jobs: needs: test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - # - name: Authenticate with Google Cloud - # uses: google-github-actions/auth@v2 - # id: gauth - # with: - # token_format: access_token - # project_id: dengenlabs - # service_account: gar-pusher@dengenlabs.iam.gserviceaccount.com - # workload_identity_provider: projects/265888598630/locations/global/workloadIdentityPools/composable-cloud/providers/github - # access_token_lifetime: 300s - # create_credentials_file: true + - name: Checkout source code + uses: actions/checkout@v2 - # - name: Set up Docker Buildx - # uses: docker/setup-buildx-action@v3 + - name: Authenticate with Google Cloud + uses: google-github-actions/auth@v2 + id: gauth + with: + token_format: access_token + project_id: dengenlabs + service_account: gar-pusher@dengenlabs.iam.gserviceaccount.com + workload_identity_provider: projects/265888598630/locations/global/workloadIdentityPools/composable-cloud/providers/github + access_token_lifetime: 300s + create_credentials_file: true - # - name: Docker meta - # id: meta - # uses: docker/metadata-action@v5 - # with: - # # list of Docker images to use as base name for tags - # images: | - # us.gcr.io/dengenlabs/agents/vertesia/github-agent - # tags: | - # type=ref,event=branch - # type=ref,event=pr - # type=sha,format=long,prefix= + - name: Get Vertesia API key + run: | + export VT_API_KEY="$(gcloud secrets versions access latest --secret=release-notes-api-key)" + echo "::add-mask::${VT_API_KEY}" + echo "VT_API_KEY=${VT_API_KEY}" >> $GITHUB_ENV - # - name: Login to GAR - # uses: docker/login-action@v3 - # with: - # registry: us.gcr.io - # username: oauth2accesstoken - # password: ${{ steps.gauth.outputs.access_token }} + - name: Set up Vertesia CLI + run: | + npm install -g @vertesia/cli + bin/init-vertesia-profile.sh + vertesia profiles + + - name: Connect to Vertesia NPM registry + run: | + cd apps/github-agent + vertesia agent connect - # - name: Build and push Docker image - # uses: docker/build-push-action@v6 - # with: - # context: . - # file: ./apps/github-agent/Dockerfile - # push: ${{ github.ref == 'refs/heads/main' }} - # tags: ${{ steps.meta.outputs.tags }} - # labels: ${{ steps.meta.outputs.labels }} - # secret-files: | - # "gcp=${{ steps.gauth.outputs.credentials_file_path }}" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + us.gcr.io/dengenlabs/agents/vertesia/github-agent + tags: | + type=ref,event=branch + type=ref,event=pr + type=sha,format=long,prefix= + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: ./apps/github-agent/Dockerfile + push: ${{ github.ref == 'refs/heads/main' }} + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/bin/init-vertesia-profile.sh b/bin/init-vertesia-profile.sh new file mode 100755 index 0000000..6dd3bbe --- /dev/null +++ b/bin/init-vertesia-profile.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# All the env vars must be set +set -u + +# Environment variables +# - VT_API_KEY: Vertesia API token +# - VT_ACCOUNT: Vertesia account ID +# - VT_PROJECT: Vertesia project ID +# - VT_ENV: Vertesia environment in which the interaction is defined +# - VT_SITE: Vertesia site in which the interaction is defined +# - VT_PROFILE: Vertesia profile name + +mkdir -p ~/.vertesia +cat <> ~/.vertesia/profiles.json +{ + "default": "${VT_PROFILE}", + "profiles": [ + { + "name": "${VT_PROFILE}", + "config_url": "https://${VT_SITE}/cli", + "account": "${VT_ACCOUNT}", + "project": "${VT_PROJECT}", + "studio_server_url": "https://studio-server-${VT_ENV}.api.vertesia.io", + "zeno_server_url": "https://zeno-server-${VT_ENV}.api.vertesia.io", + "apikey": "${VT_API_KEY}" + } + ] +} +EOF + +echo "Vertesia profile created: ~/.vertesia/profiles.json"