Skip to content

Commit

Permalink
Fix manifest creation error
Browse files Browse the repository at this point in the history
  • Loading branch information
simao-silva committed Sep 26, 2024
1 parent e3f0dcd commit 5285885
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 219 deletions.
208 changes: 0 additions & 208 deletions .github/workflows/docker build and push.yml

This file was deleted.

102 changes: 102 additions & 0 deletions .github/workflows/docker_build_and_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: image build and push

on:
push:
branches:
- "main"
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"

env:
IMAGE_NAME: "simaofsilva/drone-cli"
CLI_VERSION: "v1.8.0" # renovate: datasource=github-tags depName=harness/drone-cli

jobs:
env_vars:
name: Expose environment variables
runs-on: ubuntu-latest
outputs:
IMAGE_NAME: ${{ env.IMAGE_NAME }}
CLI_VERSION: ${{ env.CLI_VERSION }}
steps:
- run: echo "Exposing environment variables to reusable workflows."

build:
needs: env_vars
uses: ./.github/workflows/docker_reusable.yml
strategy:
matrix:
targets:
- ARCH: amd64
TARGET_PLATFORM: linux/amd64
IMAGE_NAME: "${{ needs.env_vars.outputs.IMAGE_NAME }}:${{ needs.env_vars.outputs.CLI_VERSION }}-linux-amd64"
- ARCH: arm
TARGET_PLATFORM: linux/arm/v6
IMAGE_NAME: "${{ needs.env_vars.outputs.IMAGE_NAME }}:${{ needs.env_vars.outputs.CLI_VERSION }}-linux-armv6"
- ARCH: arm
TARGET_PLATFORM: linux/arm/v7
IMAGE_NAME: "${{ needs.env_vars.outputs.IMAGE_NAME }}:${{ needs.env_vars.outputs.CLI_VERSION }}-linux-armv7"
- ARCH: arm64
TARGET_PLATFORM: linux/arm64/v8
IMAGE_NAME: "${{ needs.env_vars.outputs.IMAGE_NAME }}:${{ needs.env_vars.outputs.CLI_VERSION }}-linux-arm64v8"
with:
IMAGE_NAME: ${{ matrix.targets.IMAGE_NAME }}
VERSION: ${{ needs.env_vars.outputs.CLI_VERSION }}
ARCH: ${{ matrix.targets.ARCH }}
TARGET_PLATFORM: ${{ matrix.targets.TARGET_PLATFORM }}
secrets: inherit

build-manifest:
needs: [build]
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: create manifest for ARM64 variant
run: |
docker manifest create --amend ${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-arm64 \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-arm64v8
- name: push manifest for ARM64 variant
run: docker manifest push ${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-arm64

- name: create manifest for version ${{ env.CLI_VERSION }}
run: |
docker manifest create --amend ${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }} \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-amd64 \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-arm64v8 \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-armv7 \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-armv6
- name: push manifest for version ${{ env.CLI_VERSION }}
run: docker manifest push ${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}

- name: create manifest for linux version
run: |
docker manifest create --amend ${{ env.IMAGE_NAME }}:linux \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-amd64 \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-arm64v8 \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-armv7 \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-armv6
- name: push manifest for linux version
run: docker manifest push ${{ env.IMAGE_NAME }}:linux

- name: create manifest for latest version
run: |
docker manifest create --amend ${{ env.IMAGE_NAME }}:latest \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-amd64 \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-arm64v8 \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-armv7 \
${{ env.IMAGE_NAME }}:${{ env.CLI_VERSION }}-linux-armv6
- name: push manifest for latest version
run: docker manifest push ${{ env.IMAGE_NAME }}:latest
54 changes: 54 additions & 0 deletions .github/workflows/docker_reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Image build and push

on:
workflow_call:
inputs:
IMAGE_NAME:
description: "The image name"
type: string
required: true
VERSION:
description: "The version of the CLI to build"
type: string
required: true
ARCH:
description: "The architecture to build"
type: string
required: true
TARGET_PLATFORM:
description: "The platform to build against"
type: string
required: true

jobs:
build-push:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

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

- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: ${{ inputs.TARGET_PLATFORM }}
push: true
provenance: false
tags: ${{ inputs.IMAGE_NAME }}
file: Dockerfile
build-args: |
VERSION=${{ inputs.VERSION }}
ARCH=${{ inputs.ARCH }}
15 changes: 4 additions & 11 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
{
"extends": [
"config:base",
"config:recommended",
":disableDependencyDashboard"
],
"prHourlyLimit": 0,
"packageRules": [
{
"matchManagers": [
"github-actions"
],
"matchPackageNames": [
"docker/build-push-action"
],
"allowedVersions": "<4"
},
{
"matchUpdateTypes": [
"major",
Expand All @@ -24,7 +15,9 @@
"digest"
],
"automerge": true,
"automergeType": "branch"
"automergeType": "pr",
"automergeStrategy": "squash",
"ignoreTests": false
}
],
"regexManagers": [
Expand Down

0 comments on commit 5285885

Please sign in to comment.