Skip to content

Commit

Permalink
Add common subworkflow
Browse files Browse the repository at this point in the history
  • Loading branch information
greggbjensen committed Aug 13, 2024
1 parent 1e12852 commit 3effaf4
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 93 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/_container-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "[Subworkflow] Build Image"

on:
workflow_call:
inputs:
service_name:
description: Name of the service and root folder it comes from.
required: true
type: string
jobs:
build:
name: Build
runs-on: ubuntu-latest
concurrency:
group: build-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOCKER_BUILDKIT: 1
HELM_EXPERIMENTAL_OCI: 1
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
sparse-checkout: ${{ inputs.service_name }}

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker build and push
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name == 'release' && github.event.action == 'created' }}
tags: ${{ (github.event_name == 'release' && github.release.tag_name) && format('greggbjensen/{0}:latest, greggbjensen/{0}:{1}', inputs.service_name, github.release.tag_name) || format('greggbjensen/{0}:temp', inputs.service_name) }}
file: ${{ inputs.service_name }}/Dockerfile
context: ${{ inputs.service_name }}
37 changes: 6 additions & 31 deletions .github/workflows/prdeploy-api-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,9 @@ on:
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-latest
concurrency:
group: build-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOCKER_BUILDKIT: 1
HELM_EXPERIMENTAL_OCI: 1
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
sparse-checkout: prdeploy-api

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker build and push
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name == 'release' && github.event.action == 'created' }}
tags: ${{ (github.event_name == 'release' && github.release.tag_name) && format('greggbjensen/prdeploy-api:latest, greggbjensen/prdeploy-api:{0}', github.release.tag_name) || 'greggbjensen/prdeploy-api:temp' }}
file: prdeploy-api/Dockerfile
context: prdeploy-api
ci:
name: CI
uses: ./.github/workflows/_container-build.yaml
secrets: inherit
with:
service_name: prdeploy-api
37 changes: 6 additions & 31 deletions .github/workflows/prdeploy-app-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,9 @@ on:
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-latest
concurrency:
group: build-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOCKER_BUILDKIT: 1
HELM_EXPERIMENTAL_OCI: 1
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
sparse-checkout: prdeploy-app

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker build and push
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name == 'release' && github.event.action == 'created' }}
tags: ${{ (github.event_name == 'release' && github.release.tag_name) && format('greggbjensen/prdeploy-app:latest, greggbjensen/prdeploy-app:{0}', github.release.tag_name) || 'greggbjensen/prdeploy-app:temp' }}
file: prdeploy-app/Dockerfile
context: prdeploy-app
ci:
name: CI
uses: ./.github/workflows/_container-build.yaml
secrets: inherit
with:
service_name: prdeploy-app
37 changes: 6 additions & 31 deletions .github/workflows/prdeploy-webhooks-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,9 @@ on:
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-latest
concurrency:
group: build-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOCKER_BUILDKIT: 1
HELM_EXPERIMENTAL_OCI: 1
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
sparse-checkout: prdeploy-webhooks

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker build and push
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name == 'release' && github.event.action == 'created' }}
tags: ${{ (github.event_name == 'release' && github.release.tag_name) && format('greggbjensen/prdeploy-webhooks:latest, greggbjensen/prdeploy-webhooks:{0}', github.release.tag_name) || 'greggbjensen/prdeploy-webhooks:temp' }}
file: prdeploy-webhooks/Dockerfile
context: prdeploy-webhooks
ci:
name: CI
uses: ./.github/workflows/_container-build.yaml
secrets: inherit
with:
service_name: prdeploy-webhooks

0 comments on commit 3effaf4

Please sign in to comment.