Skip to content

Commit

Permalink
Merge pull request #214 from KeychainMDIP/refactor-docker-build-push
Browse files Browse the repository at this point in the history
Refactor docker build push
  • Loading branch information
Edgeman-SelfID authored Jul 3, 2024
2 parents 0c6626b + 4aa2654 commit 0451e51
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 91 deletions.
94 changes: 53 additions & 41 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,69 @@ env:
IMAGE_NAME: ${{ github.repository }}

jobs:
build-image:
generate:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

outputs:
CALVER: ${{ steps.calculate-calver.outputs.calver }}
REGISTRY: ${{ env.REGISTRY }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Generate CalVer Tag
id: calver
run: echo "::set-output name=version::v$(date +'%y.%m.%d')"
uses: actions/checkout@v4
- name: Compute outputs
run: |
echo "REGISTRY=${{ env.REGISTRY }}" >> $GITHUB_OUTPUT
- name: Calculate Calver
id: calculate-calver
run: |
calver=$(date +'%Y.%m.%d')
echo "calver=$calver" >> $GITHUB_ENV
echo "::set-output name=calver::$calver"
build_test_images:
runs-on: ubuntu-latest
needs: generate
strategy:
fail-fast: false
matrix:
include:
- dockerfile: Dockerfile.gatekeeper
tags: |
${{ needs.generate.outputs.REGISTRY }}/keychainmdip/gatekeeper:${{ needs.generate.outputs.CALVER }}
- dockerfile: Dockerfile.keymaster
tags: |
${{ needs.generate.outputs.REGISTRY }}/keychainmdip/keymaster:${{ needs.generate.outputs.CALVER }}
- dockerfile: Dockerfile.hyperswarm
tags: |
${{ needs.generate.outputs.REGISTRY }}/keychainmdip/hyperswarm-mediator:${{ needs.generate.outputs.CALVER }}
- dockerfile: Dockerfile.tess
tags: |
${{ needs.generate.outputs.REGISTRY }}/keychainmdip/tess-mediator:${{ needs.generate.outputs.CALVER }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build gatekeeper image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: Dockerfile.gatekeeper
push: false
tags: |
${{ env.REGISTRY }}/keychainmdip/gatekeeper:${{ steps.calver.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build keymaster image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
- name: Log in to the Container registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
with:
context: .
file: Dockerfile.keymaster
push: false
tags: |
${{ env.REGISTRY }}/keychainmdip/keymaster:${{ steps.calver.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build hyperswarm mediator image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
context: .
file: Dockerfile.hyperswarm
push: false
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
${{ env.REGISTRY }}/keychainmdip/hyperswarm-mediator:${{ steps.calver.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}
${{ needs.generate.outputs.CALVER }}
release
- name: Build TESS mediator image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
- name: Build Docker images
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c
with:
context: .
file: Dockerfile.tess
file: ${{ matrix.dockerfile }}
push: false
tags: |
${{ env.REGISTRY }}/keychainmdip/tess-mediator:${{ steps.calver.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
101 changes: 51 additions & 50 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Build and publish Docker images
name: Build & Publish

on:
push:
Expand All @@ -18,76 +18,77 @@ env:
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
generate:
runs-on: ubuntu-latest
outputs:
CALVER: ${{ steps.calculate-calver.outputs.calver }}
REGISTRY: ${{ env.REGISTRY }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Compute outputs
run: |
echo "REGISTRY=${{ env.REGISTRY }}" >> $GITHUB_OUTPUT
- name: Calculate Calver
id: calculate-calver
run: |
calver=$(date +'%Y.%m.%d')
echo "calver=$calver" >> $GITHUB_ENV
echo "::set-output name=calver::$calver"
build_test_images:
runs-on: ubuntu-latest
needs: generate
strategy:
fail-fast: false
matrix:
include:
- dockerfile: Dockerfile.gatekeeper
tags: |
${{ needs.generate.outputs.REGISTRY }}/keychainmdip/gatekeeper:${{ needs.generate.outputs.CALVER }}
${{ needs.generate.outputs.REGISTRY }}/keychainmdip/gatekeeper:release
- dockerfile: Dockerfile.keymaster
tags: |
${{ needs.generate.outputs.REGISTRY }}/keychainmdip/keymaster:${{ needs.generate.outputs.CALVER }}
${{ needs.generate.outputs.REGISTRY }}/keychainmdip/keymaster:release
- dockerfile: Dockerfile.hyperswarm
tags: |
${{ needs.generate.outputs.REGISTRY }}/keychainmdip/hyperswarm-mediator:${{ needs.generate.outputs.CALVER }}
${{ needs.generate.outputs.REGISTRY }}/keychainmdip/hyperswarm-mediator:release
- dockerfile: Dockerfile.tess
tags: |
${{ needs.generate.outputs.REGISTRY }}/keychainmdip/tess-mediator:${{ needs.generate.outputs.CALVER }}
${{ needs.generate.outputs.REGISTRY }}/keychainmdip/tess-mediator:release
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Generate CalVer Tag
id: calver
run: echo "::set-output name=version::v$(date +'%y.%m.%d')"
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
${{ steps.calver.outputs.version }}
${{ needs.generate.outputs.CALVER }}
release
- name: Build and push gatekeeper image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: Dockerfile.gatekeeper
push: true
tags: |
${{ env.REGISTRY }}/keychainmdip/gatekeeper:${{ steps.calver.outputs.version }}
${{ env.REGISTRY }}/keychainmdip/gatekeeper:release
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push keymaster image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
- name: Build and push Docker images
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c
with:
context: .
file: Dockerfile.keymaster
file: ${{ matrix.dockerfile }}
push: true
tags: |
${{ env.REGISTRY }}/keychainmdip/keymaster:${{ steps.calver.outputs.version }}
${{ env.REGISTRY }}/keychainmdip/keymaster:release
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push hyperswarm mediator image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: Dockerfile.hyperswarm
push: true
tags: |
${{ env.REGISTRY }}/keychainmdip/hyperswarm-mediator:${{ steps.calver.outputs.version }}
${{ env.REGISTRY }}/keychainmdip/hyperswarm-mediator:release
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push TESS mediator image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: Dockerfile.tess
push: true
tags: |
${{ env.REGISTRY }}/keychainmdip/tess-mediator:${{ steps.calver.outputs.version }}
${{ env.REGISTRY }}/keychainmdip/tess-mediator:release
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 0451e51

Please sign in to comment.