Skip to content

Containerfile and workflow improvements #1

Containerfile and workflow improvements

Containerfile and workflow improvements #1

name: Build and push container image
on:
# Manual trigger the workflow.
workflow_dispatch:
inputs:
image_registry:
required: false
default: 'quay.io/retis'
release_tags:
required: false
default: 'next'
# Every day at 02:22 AM UTC.
schedule:
- cron: "40 11 * * *"
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# This is kept intentionally separate from "Set environment"
- name: Check scheduled run
if: github.event_name == 'schedule'
run: |

Check failure on line 29 in .github/workflows/build_push_image.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/build_push_image.yaml

Invalid workflow file

You have an error in your yaml syntax on line 29
last_commit=$(git log -n1 --since=yesterday --oneline)
if [ -z "$last_commit" ]; then
echo "No new commits found, cancelling ..."
exit 1
else
echo "New commit found:"
echo " $last_commit"
echo "proceeding ..."
fi
- name: Set environment
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "IMAGE_REGISTRY=${{ github.event.inputs.image_registry }}" >> $GITHUB_ENV
echo "RELEASE_TAGS=${{ github.event.inputs.release_tags }}" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" = "schedule" ]; then
echo "IMAGE_REGISTRY=quay.io/retis" >> $GITHUB_ENV
echo "RELEASE_TAGS=next" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" = "release" ]; then
:
fi
- name: Log in to the registry
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build container image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
containerfiles: ./Containerfile
image: retis
tags: ${{ env.RELEASE_TAGS }}
- name: Push container image
id: push_image
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
- name: Summary
run: |
echo "${{ toJSON(steps.push_image.outputs) }}"