added updated openshift cli #1
Workflow file for this run
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
name: Build and Push Docker Images | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
env: | |
REGISTRY: docker.io | |
USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Get the latest tag | |
id: get-tag | |
run: | | |
TAG=$(git describe --tags --abbrev=0) | |
echo "TAG=$TAG" >> $GITHUB_ENV | |
- name: Extract image name from tag message | |
id: extract-image-name | |
run: | | |
TAG_MESSAGE=$(git tag -l --format='%(contents)' ${{ env.TAG }}) | |
if [[ "$TAG_MESSAGE" =~ build\/([^ ]+) ]]; then | |
IMAGE_NAME=${BASH_REMATCH[1]} | |
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV | |
else | |
echo "No valid image name specified in tag message." | |
exit 1 | |
fi | |
- name: Verify Dockerfile exists | |
run: | | |
if [ ! -f "$IMAGE_NAME/Dockerfile" ]; then | |
echo "Dockerfile not found in the specified directory: $IMAGE_NAME" | |
exit 1 | |
fi | |
- uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: amd64 | |
- uses: docker/setup-buildx-action@v2 | |
- uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata for Docker | |
uses: docker/metadata-action@v4 | |
id: meta | |
with: | |
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
file: ${{ env.IMAGE_NAME }}/Dockerfile | |
context: . | |
platforms: linux/amd64 | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} | |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest | |
labels: ${{ steps.meta.outputs.labels }} |