Add two new satellite bots #229
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: Build and Deploy to GKE | |
on: | |
push: | |
branches: [ "master" ] | |
env: | |
PROJECT_ID: nlc-bot-36685 | |
GAR_LOCATION: us-central1 | |
GKE_CLUSTER: main-cluster | |
GKE_ZONE: us-central1-c | |
DEPLOYMENT_NAME: satellites | |
REPOSITORY: satellites | |
IMAGE: production | |
jobs: | |
setup-build-publish-deploy: | |
name: Setup, Build, Publish, and Deploy | |
runs-on: ubuntu-latest | |
environment: production | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Configure Workload Identity Federation and generate an access token. | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
token_format: 'access_token' | |
workload_identity_provider: 'projects/742548057431/locations/global/workloadIdentityPools/github-identity-pool/providers/github-identity-provider' | |
service_account: '[email protected]' | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v2' | |
with: | |
version: '>= 363.0.0' | |
- name: Docker configuration | |
run: |- | |
echo ${{steps.auth.outputs.access_token}} | docker login -u oauth2accesstoken --password-stdin https://$GAR_LOCATION-docker.pkg.dev | |
# Get the GKE credentials so we can deploy to the cluster | |
- name: Set up GKE credentials | |
uses: google-github-actions/get-gke-credentials@v2 | |
with: | |
cluster_name: ${{ env.GKE_CLUSTER }} | |
location: ${{ env.GKE_ZONE }} | |
# Build the Docker image | |
- name: Build | |
run: |- | |
docker image build -t ${{ env.GAR_LOCATION }}-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA -f ./build/dockerfile ./ | |
# Push the Docker image to Google Artifact Registry | |
- name: Publish | |
run: |- | |
gcloud artifacts docker images delete $GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE --delete-tags || : | |
docker push $GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA | |
gcloud artifacts docker tags add $GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:latest" | |
# Deploy the Docker image to the GKE cluster | |
- name: Deploy | |
run: |- | |
kubectl delete deployments/${{ env.DEPLOYMENT_NAME }} --namespace=alpha-bot || : | |
kubectl apply -f build/deployment.yaml |