Skip to content

Commit

Permalink
Merge pull request #2 from HarryHung/feature/auto-deployment
Browse files Browse the repository at this point in the history
Auto image test and deployment
  • Loading branch information
HarryHung authored Sep 28, 2023
2 parents 23bb33e + f434ee2 commit 8b6fc99
Show file tree
Hide file tree
Showing 6 changed files with 35,906 additions and 21 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/docker-image-build-to-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Docker Image Build to Test

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_call:

jobs:
build-to-test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build the Docker image to test
run: docker build . --file Dockerfile --tag spn-pbp-amr:$(date +%s) --target test
53 changes: 53 additions & 0 deletions .github/workflows/docker-image-publish-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Docker Image Publish on Release

on:
release:
types: [published]

jobs:
build-to-test:
uses: ./.github/workflows/docker-image-build-to-test.yml

build-and-push-image:
needs: build-to-test

runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
target: app
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
20 changes: 0 additions & 20 deletions .github/workflows/push-main-to-public.yml

This file was deleted.

20 changes: 19 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM ubuntu:18.04
FROM ubuntu:18.04 as app

ARG DEBIAN_FRONTEND=noninteractive

RUN mkdir ~/.gnupg && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf

RUN apt update \
&& apt install -y -q apt-transport-https software-properties-common \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \
Expand Down Expand Up @@ -82,3 +84,19 @@ RUN cd /predictor \
ENV PATH /predictor:$PATH

ENV PATH /predictor/bLactam_MIC_Rscripts/:$PATH


# new base for testing
FROM app as test

RUN mkdir -p /test_data

COPY test_data /test_data

RUN spn_pbp_amr /test_data/contigs.fasta > result.json

RUN apt update && apt install -y -q jq

RUN jq --sort-keys . result.json > sorted_result.json && jq --sort-keys . /test_data/expected_result.json > sorted_expected_result.json

RUN cmp sorted_result.json sorted_expected_result.json
Loading

0 comments on commit 8b6fc99

Please sign in to comment.