From 609d54fbc2ec021a792a36eb23ce5ec67cf664ae Mon Sep 17 00:00:00 2001 From: Antonio Mika Date: Sun, 11 Dec 2022 19:24:31 -0500 Subject: [PATCH 1/4] Change build to use composite instead of matrix action --- .github/actions/build/build.yml | 52 +++++++++++++++++++++++++++++++++ .github/workflows/build.yml | 38 +++++++++--------------- 2 files changed, 66 insertions(+), 24 deletions(-) create mode 100644 .github/actions/build/build.yml diff --git a/.github/actions/build/build.yml b/.github/actions/build/build.yml new file mode 100644 index 00000000..10bab99f --- /dev/null +++ b/.github/actions/build/build.yml @@ -0,0 +1,52 @@ +name: Run a docker build + +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 + platform: ${{ 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 + platform: ${{ inputs.platforms }} + build-args: | + APP=${{ inputs.app }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 422540f3..a547cf52 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,12 +11,6 @@ on: branches: - main -env: - REGISTRY: ghcr.io - PLATFORM: | - linux/amd64 - linux/arm64 - jobs: test: runs-on: ubuntu-22.04 @@ -40,10 +34,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: @@ -64,22 +54,22 @@ 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 + - 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 + - name: Run docker build for pastes + uses: ./.github/actions/build + with: + app: pastes + - name: Run docker build for imgs + uses: ./.github/actions/build + with: + app: imgs build-caddy: runs-on: ubuntu-22.04 needs: test From 565f24fcb8648ffac4f394b76e26c45ef27bd9f6 Mon Sep 17 00:00:00 2001 From: Antonio Mika Date: Sun, 11 Dec 2022 19:29:07 -0500 Subject: [PATCH 2/4] Return env vars --- .github/workflows/build.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a547cf52..6df60d64 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,12 @@ on: branches: - main +env: + REGISTRY: ghcr.io + PLATFORM: | + linux/amd64 + linux/arm64 + jobs: test: runs-on: ubuntu-22.04 @@ -58,18 +64,26 @@ jobs: uses: ./.github/actions/build with: app: lists + platforms: ${{ env.PLATFORM }} + registry: ${{ env.REGISTRY }} - name: Run docker build for prose uses: ./.github/actions/build with: app: prose + platforms: ${{ env.PLATFORM }} + registry: ${{ env.REGISTRY }} - name: Run docker build for pastes uses: ./.github/actions/build with: app: pastes + platforms: ${{ env.PLATFORM }} + registry: ${{ env.REGISTRY }} - name: Run docker build for imgs uses: ./.github/actions/build with: app: imgs + platforms: ${{ env.PLATFORM }} + registry: ${{ env.REGISTRY }} build-caddy: runs-on: ubuntu-22.04 needs: test From 33923a224266bbd217212390e19467b8b4d2a97b Mon Sep 17 00:00:00 2001 From: Antonio Mika Date: Sun, 11 Dec 2022 19:33:17 -0500 Subject: [PATCH 3/4] Fix composite action --- .github/actions/build/{build.yml => action.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/actions/build/{build.yml => action.yml} (100%) diff --git a/.github/actions/build/build.yml b/.github/actions/build/action.yml similarity index 100% rename from .github/actions/build/build.yml rename to .github/actions/build/action.yml From 6100e854cbe241ff2e31d203e0baf8a84b2fe815 Mon Sep 17 00:00:00 2001 From: Antonio Mika Date: Sun, 11 Dec 2022 19:37:51 -0500 Subject: [PATCH 4/4] Use proper platforms setting --- .github/actions/build/action.yml | 6 ++++-- .github/workflows/build.yml | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 10bab99f..f1b5dcb1 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -1,5 +1,7 @@ name: Run a docker build +description: Runs a docker build in a composite action + inputs: app: description: The pico app to build @@ -36,7 +38,7 @@ runs: tags: ${{ steps.webmeta.outputs.tags }} labels: ${{ steps.webmeta.outputs.labels }} target: release-web - platform: ${{ inputs.platforms }} + platforms: ${{ inputs.platforms }} build-args: | APP=${{ inputs.app }} - name: Build and push ssh @@ -47,6 +49,6 @@ runs: tags: ${{ steps.sshmeta.outputs.tags }} labels: ${{ steps.sshmeta.outputs.labels }} target: release-ssh - platform: ${{ inputs.platforms }} + platforms: ${{ inputs.platforms }} build-args: | APP=${{ inputs.app }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6df60d64..e05ceb40 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ on: env: REGISTRY: ghcr.io - PLATFORM: | + PLATFORMS: | linux/amd64 linux/arm64 @@ -64,25 +64,25 @@ jobs: uses: ./.github/actions/build with: app: lists - platforms: ${{ env.PLATFORM }} + platforms: ${{ env.PLATFORMS }} registry: ${{ env.REGISTRY }} - name: Run docker build for prose uses: ./.github/actions/build with: app: prose - platforms: ${{ env.PLATFORM }} + platforms: ${{ env.PLATFORMS }} registry: ${{ env.REGISTRY }} - name: Run docker build for pastes uses: ./.github/actions/build with: app: pastes - platforms: ${{ env.PLATFORM }} + platforms: ${{ env.PLATFORMS }} registry: ${{ env.REGISTRY }} - name: Run docker build for imgs uses: ./.github/actions/build with: app: imgs - platforms: ${{ env.PLATFORM }} + platforms: ${{ env.PLATFORMS }} registry: ${{ env.REGISTRY }} build-caddy: runs-on: ubuntu-22.04 @@ -117,4 +117,4 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - platform: ${{ env.PLATFORM }} + platforms: ${{ env.PLATFORMS }}