-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2023 Nokia | ||
# Licensed under the BSD 3-Clause License. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
# a matrix list of variables used in the container build process | ||
# | ||
# python version are taken from ansible's support matrix - https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#support-life | ||
include: | ||
# 2.14.10 | ||
- ansible-core-image: "2.14.10:pypy3.10" | ||
runs-on: "ubuntu-22.04" | ||
|
||
- ansible-core-image: "2.14.10:py3.11" | ||
runs-on: "ubuntu-22.04" | ||
addional-tags: "latest" | ||
|
||
# 2.15.4 | ||
# - base-image: "pypy:3.10-slim" | ||
# ansible-core-version: "2.15.4" | ||
# runs-on: "ubuntu-22.04" | ||
|
||
# - base-image: "python:3.11-slim" | ||
# ansible-core-version: "2.15.4" | ||
# runs-on: "ubuntu-22.04" | ||
# addional-tags: "latest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Container build | ||
"on": | ||
release: | ||
types: | ||
- released | ||
workflow_dispatch: | ||
|
||
jobs: | ||
prepare-matrix: | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
matrix: ${{ steps.matrix.outputs.output }} | ||
steps: | ||
- name: Dump GitHub context | ||
env: | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
run: | | ||
echo "$GITHUB_CONTEXT" | ||
- uses: actions/checkout@v3 | ||
- uses: fabasoad/data-format-converter-action@main | ||
id: matrix | ||
with: | ||
input: ".github/container-matrix.yml" | ||
from: "yaml" | ||
to: "json" | ||
|
||
build: | ||
name: Build container | ||
runs-on: ubuntu-22.04 | ||
needs: prepare-matrix | ||
strategy: | ||
# fail-fast: false | ||
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }} | ||
|
||
steps: | ||
- name: Dump GitHub context | ||
env: | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
run: | | ||
echo "$GITHUB_CONTEXT" | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Process ansible core image version | ||
id: core-image | ||
run: | | ||
CORE_VERSION=$(./run.sh _transformAnsibleCoreVersion "${{ matrix.ansible-core-image }}") | ||
echo "::set-output name=core-version::$CORE_VERSION" | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
ghcr.io/${{ github.repository }}/${{ steps.core-image.outputs.core-version }} | ||
tags: | | ||
type=ref,event=tag | ||
type=ref,event=branch | ||
# git short commit | ||
type=sha | ||
- name: Build | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
load: true | ||
build-args: | | ||
BASE_IMAGE=ghcr.io/srl-labs/ansible-core/${{ matrix.ansible-core-image }} | ||
tags: app:latest | ||
|
||
- name: Test | ||
run: | | ||
sudo docker run --rm app:latest ansible-galaxy collection list | grep -q 'nokia.srlinux' || exit 1 | ||
- name: Login to GitHub Container Registry | ||
if: "!github.event.act" | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up QEMU | ||
if: "!github.event.act" | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Build and Push | ||
if: "!github.event.act" | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
build-args: | | ||
BASE_IMAGE=ghcr.io/srl-labs/ansible-core/${{ matrix.ansible-core-image }} | ||
tags: ${{ steps.meta.outputs.tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"act": true, | ||
"action": "created", | ||
"ref": "refs/tags/v0.0.1", | ||
"sha": "b7e12928f13caf61af40d3e8788649a1a8f24c22", | ||
"release": { | ||
"tag_name": "v0.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
ARG BASE_IMAGE=ghcr.io/srl-labs/ansible-core/2.14.10:pypy3.10 | ||
|
||
FROM ${BASE_IMAGE} as builder | ||
|
||
COPY . /work | ||
|
||
WORKDIR /work | ||
|
||
RUN ansible-galaxy collection install --no-cache .. | ||
|
||
FROM ${BASE_IMAGE} | ||
|
||
COPY --from=builder /root/.ansible/collections /root/.ansible/collections | ||
|
||
WORKDIR /ansible | ||
|
||
CMD [ "ansible-playbook" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters