Skip to content

Commit

Permalink
Merge pull request #1836 from kbase/trussimage
Browse files Browse the repository at this point in the history
DATAUP-128: First pass at adding support for a Truss tagged image build, based on branch named "truss"
  • Loading branch information
sychan committed Oct 3, 2020
2 parents e1c7368 + 554f20a commit 4953ad1
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/build_truss_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Build Truss Branch Image
'on':
pull_request:
branches:
- truss
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: "jsfillman"
DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}"
run: "./.github/workflows/scripts/build_truss_pr.sh\n"
17 changes: 17 additions & 0 deletions .github/workflows/scripts/build_truss_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#! /usr/bin/env bash

export MY_ORG=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $1}')
export MY_APP=$(echo $(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $2}')"-truss")
export DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
export COMMIT=$(echo "$SHA" | cut -c -7)

echo $DOCKER_TOKEN | docker login ghcr.io -u $DOCKER_ACTOR --password-stdin
docker build --build-arg BUILD_DATE="$DATE" \
--build-arg COMMIT="$COMMIT" \
--build-arg BRANCH="$GITHUB_HEAD_REF" \
--build-arg PULL_REQUEST="$PR" \
--label us.kbase.vcs-pull-req="$PR" \
-t ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" .
docker push ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR"

12 changes: 12 additions & 0 deletions .github/workflows/scripts/tag_truss_latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env bash

export MY_ORG=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $1}')
export MY_APP=$(echo $(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $2}')"-truss")
export DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
export BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
export COMMIT=$(echo "$SHA" | cut -c -7)

docker login -u "$DOCKER_ACTOR" -p "$DOCKER_TOKEN" ghcr.io
docker pull ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR"
docker tag ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" ghcr.io/"$MY_ORG"/"$MY_APP":"latest"
docker push ghcr.io/"$MY_ORG"/"$MY_APP":"latest"
26 changes: 26 additions & 0 deletions .github/workflows/tag_truss_latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Tag Latest Test Image
'on':
pull_request:
branches:
- truss
types:
- closed
jobs:
docker_tag:
runs-on: ubuntu-latest
steps:
- name: Check out GitHub Repo
if: github.event_name == 'pull_request' && github.event.action == 'closed' &&
github.event.pull_request.merged == true
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: "jsfillman"
DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}"
run: "./.github/workflows/scripts/tag_truss_latest.sh\n"
7 changes: 6 additions & 1 deletion docs/deploy_narrative.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This document describes how to release and deploy the Narrative Interface app onto the different KBase environments. It's intended for KBase developers and admins.

- Last modified: Sep. 25, 2020
- Last modified: Oct. 2, 2020

**_Table of Contents_**

Expand Down Expand Up @@ -73,6 +73,10 @@ To see your changes once the new image is created, simply open a narrative on CI

The [next](https://next.kbase.us), [appdev](https://appdev.kbase.us), and [prod](https://narrative.kbase.us) environments are all deployed using a production image.

### Deploying Narrative-Refactor

The [narrative-refactor](https://narrative-refactor.kbase.us) image is built against the "truss" branch of the repo and is called narrative-truss:pr### when still in a PR state or narrative-truss:latest after merge

#### Create Release Image

1. Create a new [pull request](https://github.com/kbase/narrative/compare) to merge the `develop` branch into `master`.
Expand Down Expand Up @@ -105,6 +109,7 @@ Once a pull request is merged from `develop` to `master` a new _production_ imag
| Environment | Image URL |
| ----------- | -------------------------------------------------------------- |
| CI | ghcr.io/kbase/narrative-develop:latest |
| Narrative-refactor| ghcr.io/kbase/narrative-truss:latest |
| Appdev | ghcr.io/kbase/narrative:appdev |
| Next | ghcr.io/kbase/narrative:next |
| Production | ghcr.io/kbase/narrative:prod |

0 comments on commit 4953ad1

Please sign in to comment.