Merge pull request #1126 from microbiomedata/1125-update-nmdc-schema-… #528
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 | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
env: | |
# We don't want to do certain steps if this is running in a fork | |
IS_ORIGINAL_REPO: ${{ github.repository == 'microbiomedata/nmdc-server' }} | |
# Used to determine if we add the special `prod` Docker image tag | |
IS_PROD_RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
# Used when sending redeploy action requests to Rancher | |
RANCHER_NAMESPACE: ${{ startsWith(github.ref, 'refs/tags/v') && 'nmdc' || 'nmdc-dev' }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
image: [server, client, worker] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
# history for all branches and tags is needed for setuptools-scm | |
fetch-depth: 0 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/microbiomedata/nmdc-server/${{ matrix.image }} | |
flavor: | | |
latest=false | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
type=raw,value=prod,enable=${{ env.IS_PROD_RELEASE }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ matrix.image == 'client' && 'web' || '.' }} | |
push: ${{ env.IS_ORIGINAL_REPO }} | |
file: ${{ matrix.image == 'worker' && 'Dockerfile.worker' || (matrix.image == 'client' && 'web/Dockerfile' || 'Dockerfile') }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
redeploy: | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
deployment: [ backend, frontend, worker ] | |
steps: | |
- name: Redeploy ${{ env.RANCHER_NAMESPACE }}:${{ env.IS_PROD_RELEASE && '' || 'portal-' }}${{ matrix.deployment }} | |
if: ${{ env.IS_ORIGINAL_REPO }} | |
uses: fjogeleit/http-request-action@v1 | |
with: | |
url: https://rancher2.spin.nersc.gov/v3/project/c-tmq7p:p-bkv45/workloads/deployment:${{ env.RANCHER_NAMESPACE }}:${{ env.IS_PROD_RELEASE && '' || 'portal-' }}${{ matrix.deployment }}?action=redeploy | |
method: POST | |
username: ${{ secrets.SPIN_USER }} | |
password: ${{ secrets.SPIN_PASSWORD }} |