Skip to content

Commit

Permalink
add Github publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcrane committed Nov 24, 2023
1 parent a79a791 commit e4594ea
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/actions/docker-build-and-push/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Docker Build & Push
description: Composite GitHub Action to build and push Docker images to GHCR.

inputs:
image-name:
description: "Name of the image to push to the GHCR repository."
required: true
dockerfile:
description: "The Dockerfile to build and push."
required: true
context:
description: "The context to use when building the Dockerfile."
required: true
github-token:
description: "The GitHub token used when interacting with GCHR."
required: true

runs:
using: "composite"
steps:
- id: checkout
uses: actions/checkout@v2
- id: docker-setup-buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- id: docker-meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/digirati-co-uk/uol-${{ inputs.image-name }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,enable=true,prefix=,format=long
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- id: docker-login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ inputs.github-token }}
- id: docker-build-push
uses: docker/build-push-action@v2
with:
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
builder: ${{ steps.docker-setup-buildx.outputs.name }}
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
push: ${{ github.actor != 'dependabot[bot]' }}
32 changes: 32 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and Publish

on:
push:
branches: [ "main" ]

jobs:

build-push-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/docker-build-and-push
name: build and push
with:
image-name: "preservation-api"
dockerfile: "Dockerfile"
context: "./LeedsExperiment/Preservation.API"
github-token: ${{ secrets.GITHUB_TOKEN }}

build-push-dashboard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/docker-build-and-push
with:
image-name: "dashboard"
dockerfile: "Dockerfile"
context: "./LeedsExperiment/Dashboard"
github-token: ${{ secrets.GITHUB_TOKEN }}


0 comments on commit e4594ea

Please sign in to comment.