Skip to content

Commit

Permalink
Merge pull request #6 from picosh/am/no-matrix
Browse files Browse the repository at this point in the history
Change build to use composite instead of matrix action
  • Loading branch information
antoniomika authored Dec 12, 2022
2 parents 1ce0105 + 6100e85 commit 09c53d9
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 20 deletions.
54 changes: 54 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Run a docker build

description: Runs a docker build in a composite action

inputs:
app:
description: The pico app to build
required: true
platforms:
description: The docker platforms to build for
required: false
default: |
linux/amd64
linux/arm64
registry:
description: The docker registry to use
required: false
default: ghcr.io

runs:
using: composite
steps:
- name: Collect web image metadata
id: webmeta
uses: docker/metadata-action@v4
with:
images: ${{ inputs.REGISTRY }}/${{ github.repository }}/${{ inputs.app }}-web
- name: Collect ssh image metadata
id: sshmeta
uses: docker/metadata-action@v4
with:
images: ${{ inputs.REGISTRY }}/${{ github.repository }}/${{ inputs.app }}-ssh
- name: Build and push web
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.webmeta.outputs.tags }}
labels: ${{ steps.webmeta.outputs.labels }}
target: release-web
platforms: ${{ inputs.platforms }}
build-args: |
APP=${{ inputs.app }}
- name: Build and push ssh
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.sshmeta.outputs.tags }}
labels: ${{ steps.sshmeta.outputs.labels }}
target: release-ssh
platforms: ${{ inputs.platforms }}
build-args: |
APP=${{ inputs.app }}
44 changes: 24 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
REGISTRY: ghcr.io
PLATFORM: |
PLATFORMS: |
linux/amd64
linux/arm64
Expand All @@ -40,10 +40,6 @@ jobs:
go test -v ./... -cover -race -coverprofile=coverage.out
go tool cover -func=coverage.out -o=coverage.out
build:
strategy:
matrix:
app: [prose, lists, pastes, imgs]
target: [ssh, web]
runs-on: ubuntu-22.04
needs: test
steps:
Expand All @@ -64,22 +60,30 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Collect image metadata
id: meta
uses: docker/metadata-action@v4
- name: Run docker build for lists
uses: ./.github/actions/build
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.app }}-${{ matrix.target }}
- name: Build and push
uses: docker/build-push-action@v3
app: lists
platforms: ${{ env.PLATFORMS }}
registry: ${{ env.REGISTRY }}
- name: Run docker build for prose
uses: ./.github/actions/build
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: release-${{ matrix.target }}
platform: ${{ env.PLATFORM }}
build-args: |
APP=${{ matrix.app }}
app: prose
platforms: ${{ env.PLATFORMS }}
registry: ${{ env.REGISTRY }}
- name: Run docker build for pastes
uses: ./.github/actions/build
with:
app: pastes
platforms: ${{ env.PLATFORMS }}
registry: ${{ env.REGISTRY }}
- name: Run docker build for imgs
uses: ./.github/actions/build
with:
app: imgs
platforms: ${{ env.PLATFORMS }}
registry: ${{ env.REGISTRY }}
build-caddy:
runs-on: ubuntu-22.04
needs: test
Expand Down Expand Up @@ -113,4 +117,4 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platform: ${{ env.PLATFORM }}
platforms: ${{ env.PLATFORMS }}

0 comments on commit 09c53d9

Please sign in to comment.