-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
132 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,63 @@ | ||
#!/bin/bash | ||
|
||
IMAGE_REPOSITORY=${REGISTRY_URI}/${REGISTRY_REPOSITORY}/${IMAGE_NAME} | ||
|
||
# determine version | ||
# if scheduled build then version is 'nightly' | ||
# else if REF is a tag then version is tag | ||
# else if REF is the default branch then version is 'edge' | ||
# else if REF is pull request then version is pull request event number | ||
VERSION=noop | ||
if [ "${GITHUB_EVENT_NAME}" == "schedule" ]; then | ||
VERSION=nightly | ||
elif [[ ${GITHUB_REF} == refs/tags/* ]]; then | ||
VERSION=${GITHUB_REF#refs/tags/} | ||
elif [[ ${GITHUB_REF} == refs/heads/* ]]; then | ||
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | ||
if [ "${GITHUB_EVENT_REPOSITORY_DEFAULT_BRANCH}" = "$VERSION" ]; then | ||
VERSION=edge | ||
fi | ||
elif [[ ${GITHUB_REF} == refs/pull/* ]]; then | ||
VERSION=pr-${GITHUB_EVENT_NUMBER} | ||
fi | ||
VERSION="${VERSION}" | ||
TAGS="${IMAGE_REPOSITORY}:${VERSION}" | ||
|
||
# if version is vMAJOR.MINOR.MICRO then also tag with vMAJOR and vMAJOR.MINOR | ||
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | ||
MINOR=${VERSION%.*} | ||
MAJOR=${MINOR%.*} | ||
TAGS="${TAGS},${IMAGE_REPOSITORY}:${MINOR},${IMAGE_REPOSITORY}:${MAJOR},${IMAGE_REPOSITORY}:latest" | ||
fi | ||
|
||
# add sha tag if not a pull request | ||
if [[ ${GITHUB_REF} != refs/pull/* ]]; then | ||
TAGS="${TAGS},${IMAGE_REPOSITORY}:sha-${GITHUB_SHA::12}" | ||
fi | ||
|
||
# if a flavor is provided then iterate each tag and add the flavor to it | ||
# if IMAGE_IS_DEFAULT_FLAVOR is also true, then also use the unflavored tags | ||
if [[ ${IMAGE_TAG_FLAVOR} ]] ; then | ||
original_tags=$TAGS | ||
TAGS="" | ||
|
||
for original_tag in $(echo $original_tags | sed "s/,/ /g") | ||
do | ||
if [[ ${IMAGE_IS_DEFAULT_FLAVOR} =~ true|True|t|T|yes|Yes|y|Y ]]; then | ||
new_tags="${original_tag},${original_tag}${IMAGE_TAG_FLAVOR}" | ||
else | ||
new_tags="${original_tag}${IMAGE_TAG_FLAVOR}" | ||
fi | ||
|
||
if [[ ${TAGS} ]]; then | ||
TAGS="${TAGS},${new_tags}" | ||
else | ||
TAGS="${new_tags}" | ||
fi | ||
done | ||
fi | ||
|
||
# set output for future github action steps | ||
echo "version=${VERSION}${IMAGE_TAG_FLAVOR}" >> $GITHUB_OUTPUT | ||
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | ||
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT |
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,69 @@ | ||
--- | ||
name: publish | ||
|
||
on: | ||
schedule: | ||
- cron: '0 10 * * *' # everyday at 10am | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*.*.*' | ||
pull_request: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
GITHUB_EVENT_REPOSITORY_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} | ||
GITHUB_EVENT_NUMBER: ${{ github.event.number }} | ||
REGISTRY_URI: ${{ vars.REGISTRY_URI }} | ||
REGISTRY_REPOSITORY: ${{ vars.REGISTRY_REPOSITORY }} | ||
|
||
jobs: | ||
e-kustomzie-with-ocm-policygenerator-plugin-and-helm: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
IMAGE_NAME: ee-kustomzie-with-ocm-policygenerator-plugin-and-helm | ||
IMAGE_TAG_LOCAL: localhost:5000/${{ vars.REGISTRY_REPOSITORY }}/ploigos-base:latest.ubi8 | ||
|
||
services: | ||
registry: | ||
image: registry:2 | ||
ports: | ||
- 5000:5000 | ||
|
||
outputs: | ||
version: ${{ steps.prep.outputs.version }} | ||
|
||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/[email protected] | ||
|
||
- name: Determine Image Version and Tags ⚙️ | ||
id: prep | ||
run: ${GITHUB_WORKSPACE}/.github/scripts/determine-image-version.sh | ||
|
||
- name: Version 📌 | ||
run: echo ${{ steps.prep.outputs.version }} | ||
|
||
- name: Image Tags 🏷 | ||
run: echo ${{ steps.prep.outputs.tags }} | ||
|
||
- name: Install ansible-builder 🧰 | ||
run: pip install ansible-builder | ||
|
||
- name: Build Ansible EE container image | ||
run: | | ||
ansible-builder build -v3 | ||
- name: Log in to ${{ vars.REGISTRY_URI }} 🔑 | ||
uses: redhat-actions/[email protected] | ||
with: | ||
registry: ${{ vars.REGISTRY_URI }} | ||
username: ${{ secrets.REGISTRY_USERNAME }} | ||
password: ${{ secrets.REGISTRY_PASSWORD }} |