Skip to content

Commit

Permalink
Add build job
Browse files Browse the repository at this point in the history
  • Loading branch information
whitfiea committed Oct 21, 2024
1 parent 742fe96 commit 9a117b4
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 24 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/ansible-ee-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build Ansible Execution Environment Image
on:
push:
branches:
- '**'
tags-ignore:
- '**'
jobs:
ansible-ee-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
# Without this option, we don't get the tag information
with:
fetch-depth: 0

- name: Initialise the build system
run: |
chmod u+x $GITHUB_WORKSPACE/build/bin/*.sh
$GITHUB_WORKSPACE/build/bin/initbuild.sh
source $GITHUB_WORKSPACE/build/bin/.functions.sh
- name: Build the Ansible execution environment
run: |
$GITHUB_WORKSPACE/build/bin/build-execution-environment.sh
- name: Push the container image
id: docker-push
run: |
docker tag ibmmas/ansible-devops-ee quay.io/ibmmas/ansible-devops-ee:${{ env.DOCKER_TAG }}
docker images
docker login --username "${{ secrets.QUAYIO_USERNAME }}" --password "${{ secrets.QUAYIO_PASSWORD }}" quay.io
docker push quay.io/ibmmas/ansible-devops-ee:${{ env.DOCKER_TAG }}
- name: Push the container image (master)
id: docker-push-master
if: github.ref == 'refs/heads/master'
run: |
docker tag ibmmas/ansible-devops-ee quay.io/ibmmas/ansible-devops-ee:master
docker images
docker push quay.io/ibmmas/ansible-devops-ee:master
- name: Push the container image (latest)
id: docker-push-latest
if: github.event_name == 'release'
run: |
docker tag ibmmas/ansible-devops-ee quay.io/ibmmas/ansible-devops-ee:latest
docker images
docker push quay.io/ibmmas/ansible-devops-ee:latest
--enableRetired
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

.PHONY: build install clean all
.PHONY: build build-ee install clean all

.DEFAULT_GOAL := all

Expand All @@ -10,5 +10,7 @@ install:
ansible-galaxy collection install ibm-mas_devops-100.0.0.tar.gz --force --no-deps
clean:
rm ibm-mas_devops-100.0.0.tar.gz
build-ee:
ansible-build --prune-images --file build/ee/execution-environment.yml

all: build install
11 changes: 11 additions & 0 deletions build/bin/.functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ function install_yq() {
python -m pip install yq || exit 1
}

function install_yq_farah() {
curl -L "https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_linux_amd64" > /usr/bin/yq
chmod 755 /usr/bin/yq
yq --version || exit 1
}

# Install ansible-builder
# ----------
function install_ansible_builder() {
python -m pip install ansible-builder || exit 1
}

# These should be loaded already, but just incase!
# ------------------------------------------------
Expand Down
30 changes: 30 additions & 0 deletions build/bin/build-execution-environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
set -e

echo_h1 "Ansible Execution Environment Build"

if [ "$DEV_MODE" != "true" ]; then
source ${GITHUB_WORKSPACE}/build/bin/.env.sh
source ${GITHUB_WORKSPACE}/build/bin/.functions.sh
install_yq_farah
install_ansible_builder
fi

yq -i "(.collections.[] | select(.name == \"ibm.mas_devops\") | .version)=\"${VERSION}\"" $GITHUB_WORKSPACE/build/ee/requirements.yml
yq -i "(.options.tags.[] |= sub(\"VERSION\"; env(VERSION)))" $GITHUB_WORKSPACE/build/ee/execution-environment.yml

if [ "${GITHUB_REF_NAME}" == "master" ]; then
yq '(.options.tags += ["ibmmas/ansible-devops-ee:master"])'
fi

if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
yq '(.options.tags += ["ibmmas/ansible-devops-ee:latest"])'
fi

echo_h2 "requirements.yml:"
cat $GITHUB_WORKSPACE/build/ee/requirements.yml
echo
echo_h2 "execution-environment.yml:"
cat $GITHUB_WORKSPACE/build/ee/execution-environment.yml

ansible-build build --file build/ee/execution-environment.yml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 9 additions & 18 deletions execution-environment.yml → build/ee/execution-environment.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
version: 3

# build_arg_defaults:
# ANSIBLE_GALAXY_CLI_COLLECTION_OPTS: '--pre'

dependencies:
galaxy: requirements.yml
# python: requirements.txt
system: bindep.txt

images:
dependencies:
galaxy: build/ee/requirements.yml
system: build/ee/bindep.txt
images:
base_image:
name: registry.redhat.io/ansible-automation-platform-24/ee-supported-rhel9:latest

# Custom package manager path for the RHEL based images
options:
# Custom package manager path for the RHEL based images
options:
package_manager_path: /usr/bin/microdnf
tags:
- ibmmas/ansible-devops-ee:latest
- ibmmas/ansible-devops-ee:VERSION

additional_build_files:
- src: install
- src: build/bin
dest: install

additional_build_steps:
additional_build_steps:
prepend_base:
- RUN echo This is a prepend base command!
- COPY _build/install /tmp/install

prepend_final: |
RUN whoami
RUN cat /etc/os-release
Expand Down
4 changes: 4 additions & 0 deletions build/ee/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
collections:
- name: ibm.mas_devops
version: "100.0.0"
1 change: 1 addition & 0 deletions ibm/mas_devops/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies:
"kubernetes.core": ">=2.4.0,<3.0.0"
"ibm.cloudcollection": ">=1.37.1,<2.0.0"
"ansible.utils": ">=2.11.0"
"community.general": ">=9.5.0"
repository: https://github.com/ibm-mas/ansible-devops
documentation: https://ibm-mas.github.io/ansible-devops/
homepage: https://ibm-mas.github.io/ansible-devops/
Expand Down
5 changes: 0 additions & 5 deletions requirements.yml

This file was deleted.

0 comments on commit 9a117b4

Please sign in to comment.