mirror of
https://github.com/ansible/awx-operator.git
synced 2026-03-26 21:33:14 +00:00
multi-architecture builds and publish (#1681)
* Add multi-arch image builds to makefile * A default set of platforms is specified and will build those if var `PLATFORMS` is not specified on the CLI * Builds containers and stores @ghcr with tag that is git commit. * Pushes the image to quay.io/ansible with tag devel. * Update Promote to use single build point and the multi-arch manifest - Pulls the complete manifest containing all architectures that matches the version from ghcr - Tag manifest with the specified version and publish to quay.io - Tag manifest as 'latest' and publish to quay.io Author: jon-nfc Co-authored-by: Christian M. Adams <chadams@redhat.com> Co-authored-by: TheRealHaoLiu
This commit is contained in:
35
.github/workflows/devel.yaml
vendored
35
.github/workflows/devel.yaml
vendored
@@ -13,15 +13,36 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Build Image
|
- name: Fail if QUAY_REGISTRY not set
|
||||||
run: |
|
run: |
|
||||||
IMG=awx-operator:devel make docker-build
|
if [[ -z "${{ vars.QUAY_REGISTRY }}" ]]; then
|
||||||
|
echo "QUAY_REGISTRY not set. Please set QUAY_REGISTRY in variable GitHub Actions variables."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Push To Quay
|
- name: Log into registry ghcr.io
|
||||||
uses: redhat-actions/push-to-registry@v2.1.1
|
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||||
with:
|
with:
|
||||||
image: awx-operator
|
registry: ghcr.io
|
||||||
tags: devel
|
username: ${{ github.actor }}
|
||||||
registry: quay.io/ansible/
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
|
||||||
|
- name: Log into registry quay.io
|
||||||
|
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||||
|
with:
|
||||||
|
registry: ${{ vars.QUAY_REGISTRY }}
|
||||||
username: ${{ secrets.QUAY_USER }}
|
username: ${{ secrets.QUAY_USER }}
|
||||||
password: ${{ secrets.QUAY_TOKEN }}
|
password: ${{ secrets.QUAY_TOKEN }}
|
||||||
|
|
||||||
|
|
||||||
|
- name: Build and Store Image @ghcr
|
||||||
|
run: |
|
||||||
|
IMG=ghcr.io/${{ github.repository }}:${{ github.sha }} make docker-buildx
|
||||||
|
|
||||||
|
|
||||||
|
- name: Publish Image to quay.io
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create \
|
||||||
|
ghcr.io/${{ github.repository }}:${{ github.sha }} \
|
||||||
|
--tag ${{ vars.QUAY_REGISTRY }}/awx-operator:devel
|
||||||
|
|||||||
61
.github/workflows/promote.yaml
vendored
61
.github/workflows/promote.yaml
vendored
@@ -8,47 +8,76 @@ on:
|
|||||||
tag_name:
|
tag_name:
|
||||||
description: 'Name for the tag of the release.'
|
description: 'Name for the tag of the release.'
|
||||||
required: true
|
required: true
|
||||||
|
quay_registry:
|
||||||
|
description: 'Quay registry to push to.'
|
||||||
|
default: 'quay.io/ansible'
|
||||||
|
|
||||||
|
env:
|
||||||
|
QUAY_REGISTRY: ${{ vars.QUAY_REGISTRY }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
promote:
|
promote:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set TAG_NAME for workflow_dispatch event
|
- name: Set GitHub Env vars for workflow_dispatch event
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||||
run: |
|
run: |
|
||||||
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
|
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
|
||||||
|
echo "QUAY_REGISTRY=${{ github.event.inputs.quay_registry }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Set TAG_NAME for release event
|
- name: Set GitHub Env vars if release event
|
||||||
if: ${{ github.event_name == 'release' }}
|
if: ${{ github.event_name == 'release' }}
|
||||||
run: |
|
run: |
|
||||||
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
|
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Fail if QUAY_REGISTRY not set
|
||||||
|
run: |
|
||||||
|
if [[ -z "${{ env.QUAY_REGISTRY }}" ]]; then
|
||||||
|
echo "QUAY_REGISTRY not set. Please set QUAY_REGISTRY in variable GitHub Actions variables."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
depth: 0
|
depth: 0
|
||||||
|
|
||||||
- name: Log in to GHCR
|
|
||||||
run: |
|
|
||||||
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
|
||||||
|
|
||||||
- name: Log in to Quay
|
- name: Log into registry ghcr.io
|
||||||
run: |
|
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||||
echo ${{ secrets.QUAY_TOKEN }} | docker login quay.io -u ${{ secrets.QUAY_USER }} --password-stdin
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Re-tag and promote awx-operator image
|
|
||||||
|
- name: Log into registry quay.io
|
||||||
|
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||||
|
with:
|
||||||
|
registry: ${{ env.QUAY_REGISTRY }}
|
||||||
|
username: ${{ secrets.QUAY_USER }}
|
||||||
|
password: ${{ secrets.QUAY_TOKEN }}
|
||||||
|
|
||||||
|
|
||||||
|
- name: Pull Tagged Staged Image and Publish to quay.io
|
||||||
run: |
|
run: |
|
||||||
docker pull ghcr.io/${{ github.repository }}:${TAG_NAME}
|
docker buildx imagetools create \
|
||||||
docker tag ghcr.io/${{ github.repository }}:${TAG_NAME} quay.io/${{ github.repository }}:${TAG_NAME}
|
ghcr.io/${{ github.repository }}:${{ env.TAG_NAME }} \
|
||||||
docker tag ghcr.io/${{ github.repository }}:${TAG_NAME} quay.io/${{ github.repository }}:latest
|
--tag ${{ env.QUAY_REGISTRY }}/awx-operator:${{ env.TAG_NAME }}
|
||||||
docker push quay.io/${{ github.repository }}:${TAG_NAME}
|
|
||||||
docker push quay.io/${{ github.repository }}:latest
|
|
||||||
|
- name: Pull Staged Image and Publish to quay.io/${{ github.repository }}:latest
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create \
|
||||||
|
ghcr.io/${{ github.repository }}:${{ env.TAG_NAME }} \
|
||||||
|
--tag ${{ env.QUAY_REGISTRY }}/awx-operator:latest
|
||||||
|
|
||||||
|
|
||||||
- name: Release Helm chart
|
- name: Release Helm chart
|
||||||
run: |
|
run: |
|
||||||
ansible-playbook ansible/helm-release.yml -v \
|
ansible-playbook ansible/helm-release.yml -v \
|
||||||
-e operator_image=quay.io/${{ github.repository }} \
|
-e operator_image=${{ env.QUAY_REGISTRY }}/awx-operator \
|
||||||
-e chart_owner=${{ github.repository_owner }} \
|
-e chart_owner=${{ github.repository_owner }} \
|
||||||
-e tag=${TAG_NAME} \
|
-e tag=${{ env.TAG_NAME }} \
|
||||||
-e gh_token=${{ secrets.GITHUB_TOKEN }} \
|
-e gh_token=${{ secrets.GITHUB_TOKEN }} \
|
||||||
-e gh_user=${{ github.actor }} \
|
-e gh_user=${{ github.actor }} \
|
||||||
-e repo_type=https
|
-e repo_type=https
|
||||||
|
|||||||
39
.github/workflows/stage.yml
vendored
39
.github/workflows/stage.yml
vendored
@@ -37,12 +37,6 @@ jobs:
|
|||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
- name: Checkout awx
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
repository: ${{ github.repository_owner }}/awx
|
|
||||||
path: awx
|
|
||||||
|
|
||||||
- name: Checkout awx-operator
|
- name: Checkout awx-operator
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@@ -53,17 +47,20 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python3 -m pip install docker
|
python3 -m pip install docker
|
||||||
|
|
||||||
- name: Log in to GHCR
|
- name: Log into registry ghcr.io
|
||||||
run: |
|
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||||
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and stage awx-operator
|
- name: Stage awx-operator
|
||||||
working-directory: awx-operator
|
working-directory: awx-operator
|
||||||
run: |
|
run: |
|
||||||
BUILD_ARGS="--build-arg DEFAULT_AWX_VERSION=${{ github.event.inputs.default_awx_version }} \
|
BUILD_ARGS="--build-arg DEFAULT_AWX_VERSION=${{ github.event.inputs.default_awx_version }} \
|
||||||
--build-arg OPERATOR_VERSION=${{ github.event.inputs.version }}" \
|
--build-arg OPERATOR_VERSION=${{ github.event.inputs.version }}" \
|
||||||
IMAGE_TAG_BASE=ghcr.io/${{ github.repository_owner }}/awx-operator \
|
IMG=ghcr.io/${{ github.repository }}:${{ github.event.inputs.version }} \
|
||||||
VERSION=${{ github.event.inputs.version }} make docker-build docker-push
|
make docker-buildx
|
||||||
|
|
||||||
- name: Run test deployment
|
- name: Run test deployment
|
||||||
working-directory: awx-operator
|
working-directory: awx-operator
|
||||||
@@ -76,10 +73,12 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
AWX_TEST_VERSION: ${{ github.event.inputs.default_awx_version }}
|
AWX_TEST_VERSION: ${{ github.event.inputs.default_awx_version }}
|
||||||
|
|
||||||
- name: Create draft release
|
- name: Create Draft Release
|
||||||
working-directory: awx
|
id: create_release
|
||||||
run: |
|
uses: actions/create-release@v1
|
||||||
ansible-playbook tools/ansible/stage.yml \
|
env:
|
||||||
-e version=${{ github.event.inputs.version }} \
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
-e repo=${{ github.repository_owner }}/awx-operator \
|
with:
|
||||||
-e github_token=${{ secrets.GITHUB_TOKEN }}
|
tag_name: ${{ github.event.inputs.version }}
|
||||||
|
release_name: Release ${{ github.event.inputs.version }}
|
||||||
|
draft: true
|
||||||
|
|||||||
15
Makefile
15
Makefile
@@ -107,6 +107,21 @@ docker-build: ## Build docker image with the manager.
|
|||||||
docker-push: ## Push docker image with the manager.
|
docker-push: ## Push docker image with the manager.
|
||||||
${CONTAINER_CMD} push ${IMG}
|
${CONTAINER_CMD} push ${IMG}
|
||||||
|
|
||||||
|
# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
|
||||||
|
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
|
||||||
|
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
|
||||||
|
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
|
||||||
|
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> than the export will fail)
|
||||||
|
# To properly provided solutions that supports more than one platform you should use this option.
|
||||||
|
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
|
||||||
|
.PHONY: docker-buildx
|
||||||
|
docker-buildx: ## Build and push docker image for the manager for cross-platform support
|
||||||
|
- docker buildx create --name project-v3-builder
|
||||||
|
docker buildx use project-v3-builder
|
||||||
|
- docker buildx build --push $(BUILD_ARGS) --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile .
|
||||||
|
- docker buildx rm project-v3-builder
|
||||||
|
|
||||||
|
|
||||||
##@ Deployment
|
##@ Deployment
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
|
|||||||
Reference in New Issue
Block a user