Skip to content

[devel] build ansible-runner via branch #11

[devel] build ansible-runner via branch

[devel] build ansible-runner via branch #11

Workflow file for this run

---
# This workflow will build and push an AWX EE image to a container registry based upon the provided configuration
#
# Image tags will be generated based upon the event that triggered the workflow:
# - push event:
# - main branch: latest
# - devel branch: devel
# - all other branches: <branch name>-latest
# Branches must be added to the on.push.branches array above to trigger
# - pull_request event: DEV-PR-<pull_request_number>
# Branches must be added to the on.pull_request.branches array above to trigger
# - release event: <tag_name>
# - schedule event: nightly
# This will be the same configuration as the 'latest' tag, but may contain updated packages, etc. from upstream
# - all other events: <first 7 chars of commit sha>
#
# Variables:
# IMAGE_REGISTRY_URL: The container registry to push the image to (default: ghcr.io)
# IMAGE_REPOSITORY: The repository to push the image to (default: github.repository)
# IMAGE_REGISTRY_USER: The username to authenticate with the container registry (default: github.actor)
#
# Secrets:
# IMAGE_REGISTRY_TOKEN: The token to authenticate with the container registry (default: secrets.GITHUB_TOKEN)
#
name: Build & Release
on:
push:
# build and push anytime commits are merged to specified branches
branches:
- main
- devel
paths:
- ".github/workflows/release.yml"
- "./**"
- '!**/*.md'
pull_request:
branches:
- main
- devel
paths:
- ".github/workflows/release.yml"
- "./**"
- '!**/*.md'
release:
# build and push anytime a release is created
types:
- created
schedule:
- cron: "13 4 * * 1"
jobs:
ci:
runs-on: ubuntu-latest
name: CI Build (Podman)
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
- name: Build EE with Podman
run: |
ansible-builder build -v3 -t ${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}/${{ vars.IMAGE_REPOSITORY || github.repository }} --container-runtime=podman
release:
runs-on: ubuntu-latest
name: Release
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
- name: Login to Docker Container Registry
uses: docker/login-action@v3
with:
registry: ${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}
username: ${{ vars.IMAGE_REGISTRY_USER || github.actor }}
password: ${{ secrets.IMAGE_REGISTRY_TOKEN || secrets.GITHUB_TOKEN }}
- name: Generate image tag
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
elif [[ "${{ github.ref_name }}" == "devel" ]]; then
echo "IMAGE_TAG=devel" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${{ github.ref_name }}-latest" >> $GITHUB_ENV
fi
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "IMAGE_TAG=DEV-PR-${{ github.event.pull_request.number }}" >> $GITHUB_ENV
elif [[ "${{ github.event_name }}" == "release" ]]; then
echo "IMAGE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
elif [[ "${{ github.event_name }}" == "schedule" ]]; then
echo "IMAGE_TAG=nightly" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${GITHUB_SHA::7}" >> $GITHUB_ENV
fi
- name: Setup docker buildx
run: |
docker buildx create --name awx-ee-buildx
docker buildx use awx-ee-buildx
ansible-builder create -v3 --output-file=Dockerfile
- name: Build and push image linux/amd64
run: |
docker buildx build \
--platform=linux/amd64 \
--tag=${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}/${{ vars.IMAGE_REPOSITORY || github.repository }}:${{ env.IMAGE_TAG }}-amd64 \
--push \
context
- name: Build and push image linux/arm64
run: |
docker buildx build \
--platform=linux/arm64 \
--tag=${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}/${{ vars.IMAGE_REPOSITORY || github.repository }}:${{ env.IMAGE_TAG }}-arm64 \
--push \
context
- name: Create and push multi-arch manifest
run: |
docker manifest create \
${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}/${{ vars.IMAGE_REPOSITORY || github.repository }}:${{ env.IMAGE_TAG }} \
--amend ${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}/${{ vars.IMAGE_REPOSITORY || github.repository }}:${{ env.IMAGE_TAG }}-amd64 \
--amend ${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}/${{ vars.IMAGE_REPOSITORY || github.repository }}:${{ env.IMAGE_TAG }}-arm64
docker manifest push ${{ vars.IMAGE_REGISTRY_URL || 'ghcr.io' }}/${{ vars.IMAGE_REPOSITORY || github.repository }}:${{ env.IMAGE_TAG }}