Deploy Graph Container #3
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: Deploy Graph Container | |
on: | |
workflow_dispatch: | |
env: | |
GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }} | |
GCLOUD_REGION: us-east1 | |
GCLOUD_GCR: us-docker.pkg.dev | |
GCLOUD_REGISTRY_PROJECT_ID: ${{ secrets.GCLOUD_REGISTRY_PROJECT_ID }} | |
GCLOUD_REGISTRY_IMAGE_ENV: docker | |
GCLOUD_REGISTRY_IMAGE_PROJECT: ontology | |
SERVICE_NAME: ontology-annotation-network | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: temurin | |
- name: Authenticate to Google Cloud | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: '${{ secrets.GCLOUD_SA_KEY }}' | |
- name: Setup Google Cloud CLI | |
uses: 'google-github-actions/setup-gcloud@v1' | |
- name: Get project version | |
run: | | |
echo "PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV | |
- name: Maven Verify | |
run: mvn clean package -pl oan-etl -am | |
- name: Docker Login | |
run: | | |
gcloud auth configure-docker "${GCLOUD_GCR}" | |
- name: Start our builder database container | |
run: | | |
docker pull neo4j:community-bullseye | |
docker run -d --name=builder-neo4j -p7474:7474 -p7687:7687 -v ./neo4j/data:/data --env NEO4J_AUTH=neo4j/password neo4j:community-bullseye | |
- name: Fetch our data | |
run: sh oan-etl/update.sh oan-etl/data/ | |
- name: Load our neo4j data | |
run: | | |
java -jar oan-etl/target/oan-etl-${PROJECT_VERSION}.jar -d=oan-etl/data | |
docker stop builder-neo4j | |
- name: Build And Push Docker Image | |
env: | |
TESTCONTAINERS_RYUK_DISABLED: true | |
run: | | |
echo "DOCKER_IMAGE=${GCLOUD_GCR}/${GCLOUD_REGISTRY_PROJECT_ID}/${GCLOUD_REGISTRY_IMAGE_ENV}/${GCLOUD_REGISTRY_IMAGE_PROJECT}/$SERVICE_NAME:PROJECT_VERSION" >> $GITHUB_ENV | |
docker build . --tag=${DOCKER_IMAGE} | |
docker push "${DOCKER_IMAGE}" | |
- name: Tag Artifact Registry | |
run: | | |
gcloud artifacts docker tags add "${DOCKER_IMAGE}" "${GCLOUD_GCR}/${GCLOUD_REGISTRY_PROJECT_ID}/${GCLOUD_REGISTRY_IMAGE_ENV}/${GCLOUD_REGISTRY_IMAGE_PROJECT}/$SERVICE_NAME:latest" | |
- name: Deploy Cloud Run | |
run: | | |
DOCKER_IMAGE_REPOSITORY=$(docker images --format "{{.Repository}}" | grep ontology-annotation-network-etl) | |
DOCKER_IMAGE=$(docker images --format "{{.Repository}}:{{.Tag}}" "${DOCKER_IMAGE_REPOSITORY}" ) | |
gcloud run deploy $SERVICE_NAME --quiet \ | |
--image "${DOCKER_IMAGE}" --project "${GCLOUD_PROJECT_ID}" \ | |
--region "${GCLOUD_REGION}" --platform managed --allow-unauthenticated --format json \ | |
--memory 2Gi --cpu 2 --min-instances 1 --max-instances 5 --no-cpu-throttling --ingress internal-and-cloud-load-balancing --service-account "${GCLOUD_SERVICE_ACCOUNT}" | |
echo "Invoke endpoint:" | |
gcloud run services list --platform managed --format json | jq -r \ | |
'.[] | select(.metadata.name == "google-cloud-run-maven-test") | .status.address.url' |