Skip to content

Commit

Permalink
finished off deploy github action
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Mar 1, 2024
1 parent 9b73c46 commit 4d20615
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 162 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: tests

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
release:
types: [published]

defaults:
run:
shell: bash

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ["3.10", "3.12"]
fail-fast: false
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2

- name: Disable etelemetry
run: echo "NO_ET=TRUE" >> $GITHUB_ENV

- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install other dependencies
run: |
sudo apt-get update
sudo apt-get install -y libxml2-dev libxslt-dev git dcmtk
- name: Update build tools
run: python -m pip install --upgrade pip

- name: Install Xnat-Ingest
run: python -m pip install .[test]

- name: Save XNAT username/password in ~/.netrc
run: |
echo "machine localhost:8080" > $HOME/.netrc
echo "user admin" >> $HOME/.netrc
echo "password admin" >> $HOME/.netrc
- name: Pytest
run: pytest -vvs --cov xnat_ingest --cov-config .coveragerc --cov-report xml .

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

deploy:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2

- name: Set up Docker buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get Docker image tag from git tag
run: |
echo "DOCKER_IMAGE_TAG=$(git describe --tags --abbrev=0" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
context: build
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'release' }}
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
162 changes: 0 additions & 162 deletions .github/workflows/tests.yml

This file was deleted.

0 comments on commit 4d20615

Please sign in to comment.