Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/build_and_push_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build and push RE image

on:
workflow_call:
secrets:
GHCR_USERNAME:
required: true
GHCR_TOKEN:
required: true

jobs:
docker_build_image:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
-
name: Check out GitHub Repo
with:
ref: "${{ github.event.pull_request.head.sha }}"
uses: actions/checkout@v2
-
name: Set up environment
run: |
if [ ${{ github.base_ref }} == 'main' ]; then
branch=''
else
branch="-""${{ github.base_ref }}"
fi
echo "APP_IMAGE_TAG=ghcr.io/${{ github.repository }}${branch}:pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV
echo "BRANCH=${branch}" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
echo "PR=pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV
echo "VCS_REF=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c -7)" >> $GITHUB_ENV
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
-
name: Build narrative image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.APP_IMAGE_TAG }}
labels: |
org.label-schema.build-date=${{ env.BUILD_DATE }}
org.label-schema.vcs-url="https://github.com/kbase/relation_engine_api"
org.label-schema.vcs-ref=${{ env.VCS_REF }}
org.label-schema.schema-version="1.0.0-rc1"
us.kbase.vcs-branch=${{ github.head_ref }}
us.kbase.vcs-pull-req=pr-${{ env.PR }}
org.label-schema.schema-version="1.0.0-rc1"
maintainer="KBase Team"
30 changes: 12 additions & 18 deletions .github/workflows/build_test_pr.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
---
name: Build Test Image
'on':
name: Build and Test Dev Image
on:
pull_request:
branches:
- develop
types:
- opened
- synchronize
- ready_for_review

jobs:
docker_build:
runs-on: ubuntu-latest
steps:
- name: Check out GitHub Repo
if: github.event.pull_request.draft == false
with:
ref: "${{ github.event.pull_request.head.sha }}"
uses: actions/checkout@v2
- name: Build and Push to Packages
if: github.event.pull_request.draft == false
env:
PR: "${{ github.event.pull_request.number }}"
SHA: "${{ github.event.pull_request.head.sha }}"
DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}"
DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}"
run: "./.github/workflows/scripts/build_test_pr.sh\n"
run_tests:
uses: ./.github/workflows/run_tests.yaml

run_build_and_push:
uses: ./.github/workflows/build_and_push_image.yaml
needs: run_tests
secrets:
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
41 changes: 8 additions & 33 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Relation Engine test and deploy
name: Run RE tests
on:
[push, pull_request]
workflow_call:
pull_request:
types:
- opened
- synchronize
- ready_for_review

jobs:
run_tests:
runs-on: ubuntu-latest
Expand All @@ -16,34 +22,3 @@ jobs:
docker-compose build
docker-compose run re_api sh scripts/run_tests.sh
docker-compose down --remove-orphans

docker_build_and_push:
runs-on: ubuntu-latest
needs: run_tests
if: (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master') && github.event_name == 'push' && !contains(github.event.head_commit.message, 'skip_docker_build')
steps:
- name: checkout git repo
uses: actions/checkout@v2

- name: copy VERSION to TAG_NAME
shell: bash
run: |
mkdir -p .target
cp VERSION .target/TAG_NAME

- name: set env vars
shell: bash
run: |
echo "DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
echo "BRANCH=$(git symbolic-ref --short HEAD)" >> $GITHUB_ENV
echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: build and push to dockerhub
uses: opspresso/action-docker@master
with:
args: --docker
env:
USERNAME: ${{ secrets.DOCKER_USERNAME }}
PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKERFILE: "Dockerfile"
IMAGE_NAME: "kbase/relation_engine_api"
33 changes: 23 additions & 10 deletions .github/workflows/tag_environments.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
---
name: Tag Image For Deploy
'on':
on:
repository_dispatch

jobs:
tag_environments:
runs-on: ubuntu-latest
steps:
- name: Check out GitHub Repo
uses: actions/checkout@v2
- name: Tag Deploy Environments
env:
DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}"
DOCKER_TOKEN: ${{ secrets.GHCR_TOKEN }}
IMAGE_TAG: ${{ github.event.client_payload.image_tag }}
SHA: ${{ github.event.pull_request.head.sha }}
TARGET: ${{ github.event.client_payload.target }}
DEV_PROD: ${{ github.event.client_payload.dev_prod }}
run: './.github/workflows/scripts/tag_environments.sh'

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Tag and Push to Packages
shell: bash -l {0}
run: |
if [ ${{ github.event.client_payload.dev_prod }} == "dev" ] || [ ${{ github.event.client_payload.dev_prod }} == "develop" ]
then
branch="-develop"
else
branch=''
fi
echo Dev or Prod: ${{ env.DEV_PROD }}
docker pull ghcr.io/${{ github.repository }}${branch}:${{ github.event.client_payload.image_tag }}
docker tag ghcr.io/${{ github.repository }}${branch}:${{ github.event.client_payload.image_tag }} ghcr.io/${{ github.repository }}${branch}:${{ github.event.client_payload.target }}
docker push ghcr.io/${{ github.repository }}${branch}:${{ github.event.client_payload.target }}