Skip to content

Commit

Permalink
Merge pull request #24 from whiteducksoftware/feat/unify
Browse files Browse the repository at this point in the history
feat: multi-arch docker build, update actions, unify
  • Loading branch information
philwelz authored Jan 17, 2024
2 parents 792562b + 705963e commit 7e547e5
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 122 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build & Publish Images to Registry

on:
workflow_dispatch:
push:
branches:
- master
- main
- 'update/*'
- 'feature/*'
paths:
- src/**

env:
REGISTRY: ghcr.io
ORGANISATION_NAME: whiteducksoftware

jobs:
prepare:
name: prepare
runs-on: ubuntu-latest
outputs:
REGISTRY: ${{ env.REGISTRY }}
ORGANISATION_NAME: ${{ env.ORGANISATION_NAME }}
steps:
- name: vars
run: echo "Exposing ENV vars"
api:
name: build
needs: [prepare]
uses: ./.github/workflows/docker-build-api.yml
with:
REGISTRY: ${{ needs.prepare.outputs.REGISTRY }}
ORGANISATION_NAME: ${{ needs.prepare.outputs.ORGANISATION_NAME }}
webapp:
name: build
needs: [prepare]
uses: ./.github/workflows/docker-build-webapp.yml
with:
REGISTRY: ${{ needs.prepare.outputs.REGISTRY }}
ORGANISATION_NAME: ${{ needs.prepare.outputs.ORGANISATION_NAME }}
46 changes: 46 additions & 0 deletions .github/workflows/docker-build-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build & Publish FredApi to Registry

on:
workflow_call:
inputs:
### Values from CICD Workflow ###
REGISTRY:
required: true
type: string
description: 'The Container Registry that should be used.'
ORGANISATION_NAME:
type: string
required: true
description: 'The GitHub organisation name that should be used.'

jobs:
docker-build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # needed for publishing the patched image to the GitHub Container Registry

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

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3.0.0

- name: Login to GitHub Container Registry
uses: docker/login-action@v3.0.0
with:
registry: ${{ inputs.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push API
uses: docker/build-push-action@v5.1.0
with:
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
push: true
context: ./src/FredApi
file: ./src/FredApi/Dockerfile
tags: ${{ inputs.REGISTRY }}/${{ inputs.ORGANISATION_NAME }}/sample-api:latest
50 changes: 50 additions & 0 deletions .github/workflows/docker-build-webapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build & Publish WebApp to Registry

on:
workflow_call:
inputs:
### Values from CICD Workflow ###
REGISTRY:
required: true
type: string
description: 'The Container Registry that should be used.'
ORGANISATION_NAME:
type: string
required: true
description: 'The GitHub organisation name that should be used.'

jobs:
docker-build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # needed for publishing the patched image to the GitHub Container Registry
strategy:
matrix:
version: [fred,frida,fred-cap,fred-easter,fred-pirate,fred-xmas,fred-kube,fred-mvp]

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

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3.0.0

- name: Login to GitHub Container Registry
uses: docker/login-action@v3.0.0
with:
registry: ${{ inputs.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push the ${{ matrix.version }} version of the WebApp
uses: docker/build-push-action@v5.1.0
with:
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
push: true
context: ./src/WebApp
file: ./src/WebApp/Dockerfile
build-args: VERSION_FOLDER=${{ matrix.version }}
tags: ${{ inputs.REGISTRY }}/${{ inputs.ORGANISATION_NAME }}/sample-mvc:${{ matrix.version }}
122 changes: 0 additions & 122 deletions .github/workflows/docker-build.yml

This file was deleted.

0 comments on commit 7e547e5

Please sign in to comment.