Skip to content

Commit

Permalink
DDO-3366 Add build to GHA (#241)
Browse files Browse the repository at this point in the history
* Test workflow

* Make executable

* Add docker tag

* Make file executable

* Try again

* Opps

* Add test back
  • Loading branch information
knapii-developments authored Jan 8, 2024
1 parent 30128f7 commit 5dd9846
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 0 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/thurloe-build-tag-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Github action to Build thurloe, add/promote semantic tagging and then run tests

name: thurloe-build-tag-publish-and-run-tests

on:
pull_request:
paths-ignore: ['**.md']
push:
branches:
- develop
paths-ignore: ['**.md']
env:
GCR_REGISTRY: gcr.io/broad-dsp-gcr-public/thurloe
# Region-specific Google Docker repository where GOOGLE_PROJECT/REPOSITORY_NAME can be found
GOOGLE_DOCKER_REPOSITORY: us-central1-docker.pkg.dev

jobs:
thurloe-build-tag-publish-job:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- uses: 'actions/checkout@v3'

- name: Bump the tag to a new version
uses: databiosphere/github-actions/actions/[email protected]
id: tag
env:
DEFAULT_BUMP: patch
GITHUB_TOKEN: ${{ secrets.BROADBOT_TOKEN }}
RELEASE_BRANCHES: develop
WITH_V: true

# Persist output tag from bumper to $GITHUB_ENV.
- id: persist-tag
name: Persist tag
run: |
echo "DOCKER_TAG=${{ steps.tag.outputs.tag }}" >> $GITHUB_ENV
- name: Auth to GCP
id: 'auth'
uses: google-github-actions/auth@v2

with:
token_format: 'id_token'
workload_identity_provider: 'projects/1038484894585/locations/global/workloadIdentityPools/github-wi-pool/providers/github-wi-provider'
service_account: '[email protected]'
id_token_audience: "1038484894585-k8qvf7l876733laev0lm8kenfa2lj6bn.apps.googleusercontent.com"


# Install gcloud, `setup-gcloud` automatically picks up authentication from `auth`.
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'

- name: Explicitly auth Docker for Artifact Registry
run: gcloud auth configure-docker $GOOGLE_DOCKER_REPOSITORY --quiet


# Build jar to GCR
- id: build-thurloe
name: Build Thurloe jar
run: |
cd $GITHUB_WORKSPACE
./docker/build_jar.sh
# Publish jar to GCR
- id: publish-thurloe
name: Publish Thurloe
run: |
cd $GITHUB_WORKSPACE
docker build -t ${{ github.event.repository.full_name }}:${DOCKER_TAG} --pull .
docker tag ${{ github.event.repository.full_name }}:${DOCKER_TAG} ${{ env.GCR_REGISTRY }}:${DOCKER_TAG}
gcloud docker -- push $GCR_REGISTRY:${DOCKER_TAG}

report-to-sherlock:
# Report new thurloe version to Broad DevOps
uses: broadinstitute/sherlock/.github/workflows/client-report-app-version.yaml@main
needs: thurloe-build-tag-publish-job
with:
new-version: ${{ needs.thurloe-build-tag-publish-job.outputs.tag }}
chart-name: 'thurloe'
permissions:
contents: 'read'
id-token: 'write'

set-version-in-dev:
# Put new thurloe version in Broad dev environment
uses: broadinstitute/sherlock/.github/workflows/client-set-environment-app-version.yaml@main
needs: [thurloe-build-tag-publish-job, report-to-sherlock]
with:
new-version: ${{ needs.thurloe-build-tag-publish-job.outputs.tag }}
chart-name: 'thurloe'
environment-name: 'dev'
secrets:
sync-git-token: ${{ secrets.BROADBOT_TOKEN }}
permissions:
id-token: 'write'

21 changes: 21 additions & 0 deletions docker/build_jar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# This script provides an entry point to assemble the Thurloe jar file.

# Enable strict evaluation semantics
set -e


echo "building thurloe jar..."

docker run --rm -v $PWD:/working \
-v jar-cache:/root/.ivy \
-v jar-cache:/root/.ivy2 sbtscala/scala-sbt:openjdk-17.0.2_1.7.2_2.13.10 /working/docker/install.sh /working


EXIT_CODE=$?

if [ $EXIT_CODE != 0 ]; then
echo "jar build exited with status $EXIT_CODE"
exit $EXIT_CODE
fi

0 comments on commit 5dd9846

Please sign in to comment.