Skip to content

OCP/OKD cluster installation on OCI [UPI/agnostic/None/External] #110

OCP/OKD cluster installation on OCI [UPI/agnostic/None/External]

OCP/OKD cluster installation on OCI [UPI/agnostic/None/External] #110

Workflow file for this run

---
name: main
on:
pull_request:
push:
branches:
- main
tags:
- '*'
schedule:
- cron: "0 5 * * 0"
# defaults:
# run:
# working-directory: 'mtulio.okd_installer'
jobs:
# Run linters: yaml-lint and ansible-lint.
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
with:
# path: 'mtulio.okd_installer'
submodules: recursive
- name: Set up Python 3.
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install test dependencies.
run: pip3 install yamllint ansible-lint
- name: YAML-lint
run: yamllint .
- name: Ansible-lint
run: ansible-lint ./
# Run molecule tests.
# TODO: more tests should be added to molecule before running it every build.
# Disabling molecule step (and debian) until more consistent tests is added.
molecule:
name: molecule
runs-on: ubuntu-latest
needs: [lint]
strategy:
matrix:
include:
- distro: centos7
playbook: converge.yml
# - distro: debian10
# playbook: converge.yml
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
with:
# path: 'mtulio.okd_installer'
submodules: recursive
- name: Set up Python 3.
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install test dependencies.
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
# - name: Run Molecule tests.
# run: molecule test
# env:
# PY_COLORS: '1'
# ANSIBLE_FORCE_COLOR: '1'
# MOLECULE_DISTRO: ${{ matrix.distro }}
# MOLECULE_PLAYBOOK: ${{ matrix.playbook }}
# Build a Collection and save to artifacts.
build:
name: builder(Collection)
runs-on: ubuntu-latest
needs: [molecule]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# path: 'mtulio.okd_installer'
# fetch-depth: 5
submodules: recursive
- name: Build Collection
env:
VERSION: "0.0.0-ci.${{ github.run_number }}-${{ github.run_id }}"
run: |
echo "> Building VERSION=[$VERSION]"
ansible-playbook hack/ci/deploy.yml \
-e tag="$VERSION" \
-t build
echo "> Listing built artifacts: "
ls build/mtulio-okd_installer-*.tar.gz
echo "> Renaming to 'latest': "
mv -v build/mtulio-okd_installer-$VERSION.tar.gz \
/tmp/mtulio-okd_installer-latest.tar.gz
- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: mtulio-okd_installer-builds
path: /tmp/mtulio-okd_installer-latest.tar.gz
# Build a container image in PRs only, without publishing it.
build-container:
name: release container(devel)
if: ${{ github.event_name == 'pull_request' && github.base_ref == 'main' }}
runs-on: ubuntu-latest
needs: [build]
env:
VERSION: "0.0.0-dev.${{ github.run_number }}-${{ github.run_id }}"
IMAGE: quay.io/mrbraga/okd-installer
VERCEL_VERSION: 28.20.0
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# path: 'mtulio.okd_installer'
# fetch-depth: 5
submodules: recursive
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: mtulio-okd_installer-builds
path: /tmp/build/
- name: Build container image
env:
QUAY_USER: ${{ secrets.QUAY_USER }}
QUAY_PASS: ${{ secrets.QUAY_PASS }}
run: |
echo "> Check build artifacts dir /tmp/build:"
ls -l /tmp/build
echo "> Moving artifacts to local:"
mkdir ./build || true
mv -v /tmp/build/*.tar.gz ./build
echo "> Logging to Quay.io:"
podman login -u="${QUAY_USER}" -p="${QUAY_PASS}" quay.io
echo "> Build container image: ${IMAGE}:${VERSION}"
podman build -t ${IMAGE}:${VERSION} -f hack/Containerfile .
echo "> Publish container image: ${IMAGE}:${VERSION}"
podman push ${IMAGE}:${VERSION}
# Building docs preview
- name: Set step vars
id: vars
run: |
echo "cache-key-pip=pip-docs-${{ hashFiles('**/docs/requirements.txt') }}" >> $GITHUB_OUTPUT
echo "cache-dir-pip=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Set pip cache
uses: actions/cache@v3
with:
path: ${{ steps.vars.outputs.cache-dir-pip }}
key: ${{ steps.vars.outputs.cache-key-pip }}
- name: Set npm cache
uses: actions/cache@v3
with:
path: "${HOME}/.npm"
key: "npm-vercel-${VERCEL_VERSION}"
- name: Build and Deploy Preview Docs
id: verceldeploy
run: |
npm install --global vercel@${VERCEL_VERSION}
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
vercel build --token=${{ secrets.VERCEL_TOKEN }}
PREVIEW_URL=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})
echo "Discovered Preview URL: ${PREVIEW_URL}"
echo "url=$PREVIEW_URL" >> $GITHUB_OUTPUT
# Commenting in PR
- name: Find comment
uses: peter-evans/find-comment@v2
id: fbc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- id-build-comment -->'
- name: Create comment
if: steps.fbc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- id-build-comment -->
Artifacts built by CI:
- Container: ${{ env.IMAGE }}:${{ env.VERSION }}
- Docs Preview: ${{ steps.verceldeploy.outputs.url }}
reactions: rocket
- name: Update comment
if: steps.fbc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fbc.outputs.comment-id }}
body: |
<!-- id-build-comment -->
Artifacts built by CI:
- Container: ${{ env.IMAGE }}:${{ env.VERSION }}
- Docs Preview: ${{ steps.verceldeploy.outputs.url }}
reactions: hooray
edit-mode: replace
# Build a container image on main branch, publishing the 'latest' to repository.
publish-container-latest:
name: release container(latest/ci)
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# path: 'mtulio.okd_installer'
# fetch-depth: 5
submodules: recursive
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: mtulio-okd_installer-builds
path: /tmp/build/
- name: Build container image
env:
VERSION: latest
VERSION_BUILD: "0.0.0-ci.${{ github.run_number }}-${{ github.run_id }}"
IMAGE: quay.io/mrbraga/okd-installer
QUAY_USER: ${{ secrets.QUAY_USER }}
QUAY_PASS: ${{ secrets.QUAY_PASS }}
run: |
echo "> Check build artifacts dir /tmp/build:"
ls -l /tmp/build
echo "> Moving artifacts to local:"
mkdir ./build || true
mv -v /tmp/build/*.tar.gz ./build
echo "> Logging to Quay.io:"
podman login -u="${QUAY_USER}" -p="${QUAY_PASS}" quay.io
echo "> Build container image: ${IMAGE}:${VERSION_BUILD}"
podman build -t ${IMAGE}:${VERSION} -f hack/Containerfile .
podman tag ${IMAGE}:${VERSION} ${IMAGE}:${VERSION_BUILD}
echo "> Publish container image: ${IMAGE}:${VERSION} ${VERSION_BUILD}"
podman push ${IMAGE}:${VERSION}
podman push ${IMAGE}:${VERSION_BUILD}
# Build a Collection when the tag is created, publishing it to Galaxy.
release-to-galaxy:
name: release collection(Galaxy)
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# path: 'mtulio.okd_installer'
# fetch-depth: 5
submodules: recursive
- name: Get version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Deploy to Galaxy
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
BUILD_FILE: mtulio-okd_installer-${{ steps.get_version.outputs.VERSION }}.tar.gz
ANSIBLE_GALAXY_TOKEN: ${{ secrets.ANSIBLE_GALAXY_TOKEN }}
run: |
echo VERSION=[$VERSION]
ansible-playbook hack/ci/deploy.yml \
-e tag="${VERSION}" \
-t build,deploy
mv -v build/${BUILD_FILE} /tmp/${BUILD_FILE}
- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: mtulio-okd_installer-build-${{ steps.get_version.outputs.VERSION }}
path: /tmp/mtulio-okd_installer-${{ steps.get_version.outputs.VERSION }}.tar.gz
# Build a Container image with the Collection release, publishing it to repository.
publish-container-release:
name: release container(tag)
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [release-to-galaxy]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# path: 'mtulio.okd_installer'
# fetch-depth: 5
submodules: recursive
- name: Get version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: mtulio-okd_installer-build-${{ steps.get_version.outputs.VERSION }}
path: /tmp/build/
- name: Build container image
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
VERSION_BUILD: "0.0.0-ci.${{ github.run_number }}-${{ github.run_id }}"
IMAGE: quay.io/mrbraga/okd-installer
QUAY_USER: ${{ secrets.QUAY_USER }}
QUAY_PASS: ${{ secrets.QUAY_PASS }}
run: |
echo "> Check build artifacts dir /tmp/build:"
ls -l /tmp/build
echo "> Moving artifacts to local:"
mkdir ./build || true
mv -v /tmp/build/*.tar.gz ./build
echo "> Logging to Quay.io:"
podman login -u="${QUAY_USER}" -p="${QUAY_PASS}" quay.io
echo "> Build container image:"
podman build -t ${IMAGE}:${VERSION} -f hack/Containerfile .
podman tag ${IMAGE}:${VERSION} ${IMAGE}:${VERSION_BUILD}
echo "> Publish container image:"
podman push ${IMAGE}:${VERSION}
podman push ${IMAGE}:${VERSION_BUILD}