Skip to content

Commit

Permalink
Merge pull request #319 from detiber/multiRegistry
Browse files Browse the repository at this point in the history
πŸƒπŸ»β€β™‚οΈ Publish images to multiple registries
  • Loading branch information
k8s-ci-robot authored Apr 6, 2022
2 parents 365fddb + 39e04f2 commit 0c8663b
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 51 deletions.
46 changes: 46 additions & 0 deletions .github/actions/metadata/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 'Metadata'
description: 'Generate Image Metadata'
inputs:
docker_username:
description: 'docker_username'
required: true
quay_username:
description: 'quay_username'
required: true
metadata_flavor:
description: 'metadata_flavor'
required: true
metadata_tags:
description: 'metadata_tags'
required: true
outputs:
tags:
description: "generated image tags"
value: ${{ steps.meta.outputs.tags }}
labels:
description: "generated image labels"
value: ${{ steps.meta.outputs.labels }}
version:
description: "generated image version"
value: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
runs:
using: "composite"
steps:
- name: Build image urls
shell: bash
id: image-urls
env:
DOCKER_USERNAME: ${{ inputs.docker_username }}
QUAY_USERNAME: ${{ inputs.quay_username }}
run: |
IMAGES=${GHCR_REGISTRY}/${IMAGE_NAME}
[[ -n "$DOCKER_USERNAME" ]] && IMAGES=${IMAGES},${DOCKER_REGISTRY}/${IMAGE_NAME}
[[ -n "$QUAY_USERNAME" ]] && IMAGES=${IMAGES},${QUAY_REGISTRY}/${IMAGE_NAME}
echo "::set-output name=images::${IMAGES}"
- name: Docker manager metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ steps.image-urls.outputs.images }}
flavor: ${{ inputs.metadata_flavor }}
tags: ${{ inputs.metadata_tags }}
152 changes: 119 additions & 33 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ on:
push:
branches:
- main
- capi-v1 # TODO: Used for testing my fork, remove prior to merge
schedule:
- cron: "0 */4 * * *" # TODO: Run every 4 hours to soak test, should be less frequent before merge (weekly/daily/???)
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: cluster-api-provider-packet
GHCR_REGISTRY: ghcr.io/${{ github.repository_owner }}
DOCKER_REGISTRY: ${{ secrets.DOCKER_ORG }}
QUAY_REGISTRY: quay.io/${{ secrets.QUAY_ORG }}
REGISTRY: quay.io/${{ secrets.QUAY_ORG }}
metadata_flavor: latest=false
metadata_tags: type=sha

jobs:
validate:
name: "Validate ${{ matrix.target }}"
Expand Down Expand Up @@ -38,10 +43,12 @@ jobs:
${{ runner.os }}-tmp-
- name: ${{ matrix.target }}
run: make ${{ matrix.target }}

manager-image:
name: Build and push manager image
runs-on: ubuntu-latest
needs: [validate]
needs:
- validate
steps:
- name: checkout
uses: actions/checkout@v3
Expand All @@ -50,19 +57,42 @@ jobs:
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker manager metadata

- name: Generate metadata
id: meta
uses: docker/metadata-action@v3
uses: ./.github/actions/metadata
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
- name: Log in to the Container registry
docker_username: ${{ secrets.DOCKER_USERNAME }}
quay_username: ${{ secrets.QUAY_USERNAME }}
metadata_flavor: ${{ env.metadata_flavor }}
metadata_tags: ${{ env.metadata_tags }}

- name: Log in to ghcr.io
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log into DockerHub
uses: docker/login-action@v1
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
if: ${{ env.DOCKER_USERNAME != '' }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log into quay.io
uses: docker/login-action@v1
env:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
if: ${{ env.QUAY_USERNAME != '' }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Build and push manager image
uses: docker/build-push-action@v2
with:
Expand All @@ -73,10 +103,12 @@ jobs:
platforms: linux/amd64,linux/arm64
cache-from: type=gha, scope=${{ github.workflow }}
cache-to: type=gha, mode=max, scope=${{ github.workflow }}

test-release:
name: Test Release
runs-on: ubuntu-latest
needs: [validate]
needs:
- validate
steps:
- name: checkout
uses: actions/checkout@v3
Expand All @@ -88,22 +120,26 @@ jobs:
restore-keys: |
${{ runner.os }}-tools-bin-release-
${{ runner.os }}-tools-bin-
- name: Docker manager metadata
- name: Generate metadata
id: meta
uses: docker/metadata-action@v3
uses: ./.github/actions/metadata
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
docker_username: ${{ secrets.DOCKER_USERNAME }}
quay_username: ${{ secrets.QUAY_USERNAME }}
metadata_flavor: ${{ env.metadata_flavor }}
metadata_tags: ${{ env.metadata_tags }}

- name: Test Release
env:
TAG: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
TAG: ${{ steps.meta.outputs.version }}
run: make release
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: test-release
path: out/release

e2e-quickstart:
name: "E2E quickstart"
concurrency: ci-${{ github.ref }}-e2e-quickstart
Expand All @@ -127,13 +163,23 @@ jobs:
with:
name: test-release
path: out/release
- name: Set TAG env variable
run: |
echo "TAG=sha-${GITHUB_SHA::7}" >> $GITHUB_ENV

- name: Generate metadata
id: meta
uses: ./.github/actions/metadata
with:
docker_username: ${{ secrets.DOCKER_USERNAME }}
quay_username: ${{ secrets.QUAY_USERNAME }}
metadata_flavor: ${{ env.metadata_flavor }}
metadata_tags: ${{ env.metadata_tags }}

- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
env:
TAG: ${{ steps.meta.outputs.version }}
- name: "e2e-quickstart"
env:
TAG: ${{ steps.meta.outputs.version }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
Expand Down Expand Up @@ -173,13 +219,23 @@ jobs:
with:
name: test-release
path: out/release
- name: Set TAG env variable
run: |
echo "TAG=sha-${GITHUB_SHA::7}" >> $GITHUB_ENV

- name: Generate metadata
id: meta
uses: ./.github/actions/metadata
with:
docker_username: ${{ secrets.DOCKER_USERNAME }}
quay_username: ${{ secrets.QUAY_USERNAME }}
metadata_flavor: ${{ env.metadata_flavor }}
metadata_tags: ${{ env.metadata_tags }}

- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
env:
TAG: ${{ steps.meta.outputs.version }}
- name: "e2e"
env:
TAG: ${{ steps.meta.outputs.version }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
Expand Down Expand Up @@ -219,13 +275,23 @@ jobs:
with:
name: test-release
path: out/release
- name: Set TAG env variable
run: |
echo "TAG=sha-${GITHUB_SHA::7}" >> $GITHUB_ENV

- name: Generate metadata
id: meta
uses: ./.github/actions/metadata
with:
docker_username: ${{ secrets.DOCKER_USERNAME }}
quay_username: ${{ secrets.QUAY_USERNAME }}
metadata_flavor: ${{ env.metadata_flavor }}
metadata_tags: ${{ env.metadata_tags }}

- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
env:
TAG: ${{ steps.meta.outputs.version }}
- name: "e2e-conformance"
env:
TAG: ${{ steps.meta.outputs.version }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
Expand Down Expand Up @@ -265,13 +331,23 @@ jobs:
with:
name: test-release
path: out/release
- name: Set TAG env variable
run: |
echo "TAG=sha-${GITHUB_SHA::7}" >> $GITHUB_ENV

- name: Generate metadata
id: meta
uses: ./.github/actions/metadata
with:
docker_username: ${{ secrets.DOCKER_USERNAME }}
quay_username: ${{ secrets.QUAY_USERNAME }}
metadata_flavor: ${{ env.metadata_flavor }}
metadata_tags: ${{ env.metadata_tags }}

- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
env:
TAG: ${{ steps.meta.outputs.version }}
- name: "e2e-management-upgrade"
env:
TAG: ${{ steps.meta.outputs.version }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
Expand Down Expand Up @@ -311,13 +387,23 @@ jobs:
with:
name: test-release
path: out/release
- name: Set TAG env variable
run: |
echo "TAG=sha-${GITHUB_SHA::7}" >> $GITHUB_ENV

- name: Generate metadata
id: meta
uses: ./.github/actions/metadata
with:
docker_username: ${{ secrets.DOCKER_USERNAME }}
quay_username: ${{ secrets.QUAY_USERNAME }}
metadata_flavor: ${{ env.metadata_flavor }}
metadata_tags: ${{ env.metadata_tags }}

- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
env:
TAG: ${{ steps.meta.outputs.version }}
- name: "e2e-workload-upgrade"
env:
TAG: ${{ steps.meta.outputs.version }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: Pull Request Validation
on:
pull_request:
types: [opened, synchronize, reopened]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
validate:
name: "Validate ${{ matrix.target }}"
Expand Down
Loading

0 comments on commit 0c8663b

Please sign in to comment.