PLFM-8554: Run Synapse Docker registry using ECS #25
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: main | |
on: | |
pull_request: | |
branches: ['*'] | |
push: | |
branches: ['*'] | |
concurrency: ci-${{ github.ref }} | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Static Analysis | |
uses: pre-commit/[email protected] | |
- name: Install dependencies | |
run: pip install -r requirements.txt -r requirements-dev.txt | |
- name: Run unit tests | |
run: python -m pytest tests/ -s -v | |
# make sure tests pass for both dev and prod stacks | |
synth-test: | |
needs: tests | |
strategy: | |
matrix: | |
stack: ['dev', 'prod'] | |
uses: "./.github/workflows/synth-test.yml" | |
with: | |
CONTEXT: ${{ matrix.stack }} | |
build-registry-container: | |
needs: [tests, synth-test] | |
# only run on a push/merge, not on a PR | |
if: (${{ github.ref_name }} == 'dev') || (${{ github.ref_name }} == 'prod') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ghcr.io/${{ github.repository }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: create self-signed cert | |
run: > | |
openssl req -x509 -days 3650 -newkey rsa:2048 -sha256 | |
-nodes -keyout privatekey.pem -out certificate.pem | |
-subj "/C=US/ST=Seattle/L=WA/O=SageBionetworks/OU=IT/CN=synapse.org" | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
with: | |
context: . | |
build-args: stack=${{ github.ref_name }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cdk-deploy-dev: | |
# only run on a push/merge, not on a PR | |
if: ${{ github.ref_name }} == 'dev' | |
needs: [tests, synth-test, build-registry-container] | |
uses: "./.github/workflows/aws-deploy.yml" | |
secrets: inherit | |
with: | |
CONTEXT: ${{ github.ref_name }} | |
ROLE_TO_ASSUME: arn:aws:iam::449435941126:role/sagebase-github-oidc-sage-bionetworks-synapse-docker-registry | |
cdk-deploy-prod: | |
# only run on a push/merge, not on a PR | |
if: ${{ github.ref_name }} == 'prod' | |
needs: [tests, synth-test, build-registry-container] | |
uses: "./.github/workflows/aws-deploy.yml" | |
secrets: inherit | |
with: | |
CONTEXT: ${{ github.ref_name }} | |
ROLE_TO_ASSUME: arn:aws:iam::325565585839:role/sagebase-github-oidc-sage-bionetworks-synapse-docker-registry |