Skip to content
Merged
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
7 changes: 5 additions & 2 deletions .github/workflows/build_prodrc_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ jobs:
docker_build:
runs-on: ubuntu-latest
steps:
- name: Verify merge is develop -> main
if: github.head_ref != 'develop'
run: echo "Must merge from develop -> main/master"; exit 1
- name: Check out GitHub Repo
if: github.event.pull_request.draft == false
if: github.event.pull_request.draft == false && github.head_ref == 'develop'
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
if: github.event.pull_request.draft == false && github.head_ref == 'develop'
env:
PR: "${{ github.event.pull_request.number }}"
SHA: "${{ github.event.pull_request.head.sha }}"
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/prod_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Publish Release Image
'on':
release:
branches:
- main
- master
types:
- published
jobs:
docker_build:
runs-on: ubuntu-latest
steps:
- name: Check Tag
id: check-tag
run: |-
if [[ ${{ github.ref_name }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo ::set-output name=match::true
fi
- name: Report SemVer Check
if: steps.check-tag.outputs.match != 'true'
run: echo "Release version must follow semantic naming (e.g. 1.0.2)"; exit 1
- name: Check Source Branch
if: github.event.release.target_commitish != 'master' && github.event.release.target_commitish != 'main'
run: echo "Releases must be built from master/main branch"; exit 1
- name: Check out GitHub Repo
with:
ref: "${{ github.event.pull_request.head.sha }}"
uses: actions/checkout@v2
- name: Build and Push to Packages
env:
ISH: "${{ github.event.release.target_commitish }}"
PR: "${{ github.event.pull_request.number }}"
SHA: "${{ github.event.pull_request.head.sha }}"
VER: "${{ github.event.release.tag_name }}"
DOCKER_ACTOR: "${{ secrets.GHCR_USERNAME }}"
DOCKER_TOKEN: "${{ secrets.GHCR_TOKEN }}"
run: "./.github/workflows/scripts/prod_release.sh\n"
1 change: 1 addition & 0 deletions .github/workflows/scripts/build_prodrc_pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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 "Branch is:" ${GITHUB_HEAD_REF}
docker login -u "$DOCKER_ACTOR" -p "$DOCKER_TOKEN" ghcr.io
docker build --build-arg BUILD_DATE="$DATE" \
--build-arg COMMIT="$COMMIT" \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/build_test_pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ docker build --build-arg BUILD_DATE="$DATE" \
--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"


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

export MY_ORG=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $1}')
export MY_APP=$(echo "${GITHUB_REPOSITORY}" | awk -F / '{print $2}')
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 "ISH is:" $ISH
echo "GITHUB_REF is:" $GITHUB_REF
echo "HEAD_REF is:" $GITHUB_HEAD_REF
echo "BASE_REF is:" $GITHUB_BASE_REF
echo "Release is:" $GITHUB_REF_NAME
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" \
--build-arg VERSION="$VER" \
--label us.kbase.vcs-pull-req="$PR" \
-t ghcr.io/"$MY_ORG"/"$MY_APP":"$VER" \
-t ghcr.io/"$MY_ORG"/"$MY_APP":"latest" .
docker push ghcr.io/"$MY_ORG"/"$MY_APP":"$VER"
docker push ghcr.io/"$MY_ORG"/"$MY_APP":"latest"
4 changes: 2 additions & 2 deletions .github/workflows/scripts/tag_prod_latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ 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"
docker tag ghcr.io/"$MY_ORG"/"$MY_APP":"pr-""$PR" ghcr.io/"$MY_ORG"/"$MY_APP":"latest-rc"
docker push ghcr.io/"$MY_ORG"/"$MY_APP":"latest-rc"