Skip to content

Commit

Permalink
Merge pull request #1858 from kbase/DEVOPS-364
Browse files Browse the repository at this point in the history
Adding script to build `narrative-truss:latest` on any push to `truss…
  • Loading branch information
sychan committed Oct 12, 2020
2 parents 2a619e8 + 8e99a13 commit a59fd36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
---
name: Tag Latest Test Image
name: Build Truss Image Push
'on':
pull_request:
push:
branches:
- truss
types:
- closed
jobs:
docker_tag:
docker_build:
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
if: github.event.pull_request.draft == false
with:
ref: "${{ github.event.pull_request.head.sha }}"
uses: actions/checkout@v2
Expand All @@ -23,4 +20,4 @@ jobs:
SHA: "${{ github.event.pull_request.head.sha }}"
DOCKER_ACTOR: "jsfillman"
DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}"
run: "./.github/workflows/scripts/tag_truss_latest.sh\n"
run: "./.github/workflows/scripts/build_truss_push.sh\n"
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#! /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 MY_APP=$(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 build --build-arg BUILD_DATE="$DATE" \
--build-arg COMMIT="$COMMIT" \
--build-arg BRANCH="$GITHUB_HEAD_REF" \
-t ghcr.io/"$MY_ORG"/"$MY_APP":"latest" .
docker push ghcr.io/"$MY_ORG"/"$MY_APP":"latest"

0 comments on commit a59fd36

Please sign in to comment.