Skip to content

Commit

Permalink
Added multi platform build (#2)
Browse files Browse the repository at this point in the history
* added multi platform build

* added test on push

* remove tty alloc

* fix local testing with act
  • Loading branch information
hellt authored Sep 27, 2023
1 parent faef8af commit 4152335
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 52 deletions.
67 changes: 38 additions & 29 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Container build
release:
types:
- published
push:

jobs:
build:
Expand All @@ -15,14 +16,20 @@ jobs:
- python:3.10-slim

steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- name: Checkout
uses: actions/checkout@v3

# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Process base image
id: base-image
Expand Down Expand Up @@ -53,31 +60,33 @@ jobs:

- name: Test
run: |
docker run --rm -it app:latest ansible --version
docker run --rm app:latest ansible --version
# - name: Login to GitHub Container Registry
# if: github.event_name == 'release'
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: github.event_name == 'release'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# - name: Process ansible core version
# id: ansible-core-version
# run: |
# TAG_NAME=${{ github.event.release.tag_name }}
# TAG_NAME=${TAG_NAME#v} # remove the leading v
# echo "Tag name without leading v: $TAG_NAME"
# echo "::set-output name=ansible-core-version::$TAG_NAME"
- name: Process ansible core version
if: github.event_name == 'release'
id: ansible-core-version
run: |
TAG_NAME=${{ github.event.release.tag_name }}
TAG_NAME=${TAG_NAME#v} # remove the leading v
echo "Tag name without leading v: $TAG_NAME"
echo "::set-output name=ansible-core-version::$TAG_NAME"
# - name: Build and Push
# if: github.event_name == 'release'
# uses: docker/build-push-action@v4
# with:
# context: .
# push: true
# build-args: |
# BASE_IMAGE=${{ matrix.py-base-image }}
# ANSIBLE_CORE_VERSION=${{ steps.ansible-core-version.outputs.ansible-core-version }}
# tags: ${{ steps.meta.outputs.tags }}
- name: Build and Push
if: github.event_name == 'release' && !github.event.act
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
build-args: |
BASE_IMAGE=${{ matrix.py-base-image }}
ANSIBLE_CORE_VERSION=${{ steps.ansible-core-version.outputs.ansible-core-version }}
tags: ${{ steps.meta.outputs.tags }}
18 changes: 0 additions & 18 deletions .github/workflows/event-log.yml.bak

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/release-event.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"act": true,
"action": "created",
"ref": "refs/tags/v0.0.0-test2",
"ref": "refs/tags/v2.12.0",
"sha": "b7e12928f13caf61af40d3e8788649a1a8f24c22",
"release": {
"tag_name": "v0.0.0-test2"
"tag_name": "v2.12.0"
}
}
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# ansible
ansible container image
# Ansible-core container image

This repository contains the source for building ansible-core container image using the following python versions:

* pypy (slim)
* python (slim)

The image is tagged with the python backend/version and a matching ansible-core version, e.g.:

* `ghcr.io/srl-labs/ansible-core/pypy3.10:2.12.0` for pypy3.10 backend and ansible-core 2.12.0
* `ghcr.io/srl-labs/ansible-core/py3.10:2.12.0` for python3.10 backend and ansible-core 2.12.0

Images are built for linux/amd64 and linux/arm64 architectures.
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function build {

# testing release-triggered workflow
function test-act-release {
gh act -W '.github/workflows/build-release.yml' -e .github/workflows/release-event.json -s GITHUB_TOKEN="$(gh auth token)" --matrix py-base-image:pypy:3.10-slim
gh act release -W '.github/workflows/build-release.yml' -e .github/workflows/release-event.json -s GITHUB_TOKEN="$(gh auth token)" --matrix py-base-image:pypy:3.10-slim
}

# -----------------------------------------------------------------------------
Expand Down

0 comments on commit 4152335

Please sign in to comment.