Skip to content

Commit

Permalink
feat: add yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
house1313 committed Nov 19, 2024
1 parent 48cc5f7 commit c20048a
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/testnet-package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Build and Deploy
on:
push:
branches: ['dev', 'feature/*'] # if you want to trigger the Github Action on another branch add or change this
env:
DOTNET_INSTALL_DIR: "./.dotnet"
jobs:
publish:
runs-on: schrodinger-runner # this is the self-hosted runner name after it is being setup
strategy:
matrix:
servicename: [Watermark] # This should be the app that needs to be deploy.
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0' # which dotnet version is required?

- run: dotnet publish ${{ matrix.servicename }}/${{ matrix.servicename }}.csproj -o out/${{ matrix.servicename }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.servicename }}
path: out/${{ matrix.servicename }}
retention-days: 1
build-and-push-image:
needs: publish
runs-on: schrodinger-runner # this is the self-hosted runner name after it is being setup
strategy:
matrix:
servicename: [Watermark] # This should be the list of app that needs to be deploy.
permissions:
contents: read
outputs:
short_sha: ${{ steps.vars.outputs.short_sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "short_sha=$calculatedSha" >> "$GITHUB_OUTPUT"
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.servicename }}
path: out/${{ matrix.servicename }}
- name: Create image tag
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.REPOSITORY_REGION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.REPOSITORY }}/${{ matrix.servicename }}
tags: |
type=sha
- # Setting up Docker Buildx with docker-container driver is required
# at the moment to be able to use a subdirectory with Git context
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
build-args: |
servicename=${{ matrix.servicename }}
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
dispatch:
runs-on: schrodinger-runner
needs: build-and-push-image
steps:
- name: Deploy
uses: actions/github-script@v6
with:
github-token: ${{ secrets.TOK }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'Schrodinger-AI',
repo: 'devops',
workflow_id: 'deployment_testnet.yaml',
ref: 'main',
inputs: {
appName: 'schrodinger-backend',
commit_sha: 'sha-${{ needs.build-and-push-image.outputs.short_sha }}',
}
})

0 comments on commit c20048a

Please sign in to comment.