Skip to content

Commit

Permalink
Added build container workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonking3 committed Sep 29, 2023
1 parent afc7995 commit 97e5072
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
name: Release
on:
release:
types:
- created
workflow_dispatch:
inputs:
tag:
description: 'Image Tag'
required: true
type: string
default: 'latest'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/mdd


jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
if: ${{ ! inputs.tag }}
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push Docker image
if: ${{ inputs.tag }}
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.tag }}
labels: ${{ steps.meta.outputs.labels }}
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM --platform=linux/amd64 ubuntu:20.04

ARG build_date=unspecified

# workspace location
ARG WORKSPACE
ENV WORKSPACE ${WORKSPACE:-/ansible}
ENV ANSIBLE_COLLECTIONS_PATH /

COPY requirements.txt /tmp/requirements.txt
COPY requirements.yml /tmp/requirements.yml
USER root
RUN mkdir /root/.ssh && bash -c 'echo -e "Host *\n KexAlgorithms +diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1" > /root/.ssh/config'
RUN mkdir /ansible_collections && chmod 777 /ansible_collections
RUN apt-get update && \
apt-get install -y python3.8 python3-pip sshpass git && \
pip3 install --upgrade --no-cache-dir setuptools pip && \
echo "===> Installing PIP Requirements <===" && \
pip3 install --no-cache -r /tmp/requirements.txt && \
echo "===> Installing Ansible Collections <===" && \
rm -rf /var/lib/apt/lists/* && \
ansible-galaxy collection install -r /tmp/requirements.yml

ENV ANSIBLE_HOST_KEY_CHECKING=false \
ANSIBLE_RETRY_FILES_ENABLED=false \
ANSIBLE_SSH_PIPELINING=true

WORKDIR ${WORKSPACE}
16 changes: 16 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ansible==4.5.0
virl2_client==2.6.0
netaddr
pynetbox
jsonschema
ipaddress
paramiko
genie
pyats
jmespath
passlib
botocore
boto3
nso-oc==2.79.4
networkx
scipy
9 changes: 9 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
collections:
- name: https://github.com/ciscodevnet/ansible-cml.git
type: git
- source: .
type: dir
- name: https://github.com/model-driven-devops/ansible-nso.git
type: git
- name: amazon.aws
source: https://galaxy.ansible.com

0 comments on commit 97e5072

Please sign in to comment.