Linuxfabrik: Build Execution Environment #4
Workflow file for this run
This file contains hidden or 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
name: 'Linuxfabrik: Build Execution Environment' | |
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- 'v*.*.*' # any vX.Y.Z tag | |
workflow_dispatch: # yamllint disable-line rule:empty-values | |
# modify the default permissions granted to the GITHUB_TOKEN | |
permissions: | |
contents: 'read' # to checkout the code | |
packages: 'write' # to push to GitHub Container Registry | |
jobs: | |
build-ee: | |
runs-on: | |
- 'ubuntu-latest' | |
steps: | |
- name: 'git clone https://github.com/Linuxfabrik/THIS-REPO' | |
uses: 'actions/checkout@v4' | |
- name: 'Log in to GitHub Container Registry' | |
uses: 'redhat-actions/podman-login@v1' | |
with: | |
registry: 'ghcr.io' | |
username: '${{ github.actor }}' | |
password: '${{ secrets.GITHUB_TOKEN }}' | |
- name: 'Install Ansible Builder' | |
run: | | |
python3 -m pip install --upgrade pip | |
pip install ansible-builder | |
- name: 'Store the lowercase repository name' | |
run: | | |
echo "GITHUB_REPOSITORY_OWNER_LOWERCASE=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV | |
- name: 'Determine image tags' | |
id: 'determine-tags' | |
run: | | |
# tag event? | |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
# strip "refs/tags/" | |
FULL_TAG="${GITHUB_REF#refs/tags/}" | |
# strip leading "v" if present | |
SEMVER="${FULL_TAG#v}" | |
echo "TAG1=${SEMVER}" >> $GITHUB_ENV | |
echo "TAG2=latest" >> $GITHUB_ENV | |
else | |
# non-tag (push/main or manual) | |
echo "TAG1=${GITHUB_SHA}" >> $GITHUB_ENV | |
echo "TAG2=dev" >> $GITHUB_ENV | |
fi | |
- name: 'Build Execution Environment' | |
run: | | |
ansible-builder build \ | |
--tag 'ghcr.io/${{ env.GITHUB_REPOSITORY_OWNER_LOWERCASE }}/lfops_ee:${{ env.TAG1 }}' \ | |
-vvv | |
- name: 'Re-tag the image' | |
run: | | |
podman tag \ | |
'ghcr.io/${{ env.GITHUB_REPOSITORY_OWNER_LOWERCASE }}/lfops_ee:${{ env.TAG1 }}' \ | |
'ghcr.io/${{ env.GITHUB_REPOSITORY_OWNER_LOWERCASE }}/lfops_ee:${{ env.TAG2 }}' | |
- name: 'Push to GitHub Container Registry' | |
id: 'push-to-ghcr' | |
uses: 'redhat-actions/push-to-registry@v2' | |
with: | |
registry: 'ghcr.io' | |
image: '${{ env.GITHUB_REPOSITORY_OWNER_LOWERCASE }}/lfops_ee' | |
tags: '${{ env.TAG1 }} ${{ env.TAG2 }}' | |
- name: 'Show pushed image path' | |
run: 'echo "LFOps Execution Environment published to ${{ steps.push-to-ghcr.outputs.registry-path }}"' |