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
40 changes: 40 additions & 0 deletions .github/workflows/docker_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Docker Main Build

on:
push:
branches:
- main

jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set build tag
id: build_tag_generator
run: |
RELEASE_TAG=$(curl https://api.github.com/repos/hyperledger/firefly/releases/latest -s | jq .tag_name -r)
BUILD_TAG=$RELEASE_TAG-$(date +"%Y%m%d")-$GITHUB_RUN_NUMBER
echo ::set-output name=BUILD_TAG::$BUILD_TAG

- name: Build
run: |
docker build \
--label commit=$GITHUB_SHA \
--label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label tag=${{ steps.build_tag_generator.outputs.BUILD_TAG }} \
--tag ghcr.io/hyperledger/firefly:${{ steps.build_tag_generator.outputs.BUILD_TAG }} .

- name: Tag release
run: docker tag ghcr.io/hyperledger/firefly:${{ steps.build_tag_generator.outputs.BUILD_TAG }} ghcr.io/hyperledger/firefly:head

- name: Push docker image
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker push ghcr.io/hyperledger/firefly:${{ steps.build_tag_generator.outputs.BUILD_TAG }}

- name: Push head tag
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker push ghcr.io/hyperledger/firefly:head
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Docker
name: Docker Release Build

on:
release:
types: [published, prereleased]
types: [released, prereleased]

jobs:
docker:
Expand All @@ -11,10 +11,15 @@ jobs:
- uses: actions/checkout@v2

- name: Build
run: docker build -t ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} .
run: |
docker build \
--label commit=$GITHUB_SHA \
--label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label tag=${GITHUB_REF##*/} \
--tag ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} .

- name: Tag release
if: github.event.action == 'published'
if: github.event.action == 'released'
run: docker tag ghcr.io/hyperledger/firefly:${GITHUB_REF##*/} ghcr.io/hyperledger/firefly:latest

- name: Push docker image
Expand All @@ -23,7 +28,7 @@ jobs:
docker push ghcr.io/hyperledger/firefly:${GITHUB_REF##*/}

- name: Push latest tag
if: github.event.action == 'published'
if: github.event.action == 'released'
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker push ghcr.io/hyperledger/firefly:latest
31 changes: 28 additions & 3 deletions manifestgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
# This script will automatically update the manifest.json file with the
# latest releases of all FireFly microservice dependencies

USE_HEAD=false

# If you pass the string "head" as an argument to this script, it will
# get the latest build, straight off the main branch. Otherwise it will
# get the most recent release that is not a pre-release.
if [[ $# -eq 1 ]] ; then
if [[ $1 -eq "head" ]] ; then
echo 'using head'
USE_HEAD=true
fi
fi

rm -f manifest.json

SERVICES=(
Expand All @@ -36,15 +48,28 @@ do
echo " \"${SERVICES[$i]}\": {" >> manifest.json
echo " \"image\": \"ghcr.io/hyperledger/firefly-${SERVICES[$i]}\"," >> manifest.json

# Query GitHub API the latest release version
TAG=$(curl https://api.github.com/repos/hyperledger/firefly-${SERVICES[$i]}/releases/latest -s | jq .tag_name -r)
if [ $USE_HEAD = false ] ; then
# Query GitHub API the latest release version
TAG=$(curl https://api.github.com/repos/hyperledger/firefly-${SERVICES[$i]}/releases/latest -s | jq .tag_name -r)
else
# Otherwise, pull the newest built image straight off the main branch
TAG="head"
fi

# Attempt to pull the image from GitHub Container Repository
docker pull ghcr.io/hyperledger/firefly-${SERVICES[$i]}:$TAG
# Get the SHA of the downloaded image
SHA=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/hyperledger/firefly-${SERVICES[$i]}:$TAG | cut -d ':' -f 2)
# Get the tag / build number name of this image from its label
TAG_LABEL=$(docker inspect --format='{{index .Config.Labels "tag"}}' ghcr.io/hyperledger/firefly-${SERVICES[$i]}:$TAG)

# If the tag / build number wasn't set in the label, use whatever docker tag we fetched
# This is done for backwards compatability, because not all images have labels yet
if [ -z "$TAG_LABEL" ]; then
TAG_LABEL=$TAG
fi

echo " \"tag\": \"$TAG\"," >> manifest.json
echo " \"tag\": \"$TAG_LABEL\"," >> manifest.json
echo " \"sha\": \"$SHA\"" >> manifest.json
if [[ $(($i + 1)) -eq ${SERVICE_COUNT} ]]
then
Expand Down