Skip to content

build/helm-lint-test:1.0.11 #7

build/helm-lint-test:1.0.11

build/helm-lint-test:1.0.11 #7

Workflow file for this run

name: Build and Push Docker Images
on:
push:
branches:
- main # or the branch you are using
# Optionally, you can add filters if needed
# For example, you can use paths or commit message filters
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get commit message
id: get-commit-message
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV
- name: Extract image name and version from commit message
id: extract-info
run: |
if [[ "$COMMIT_MESSAGE" =~ ^build\/([^:]+):(.+)$ ]]; then
IMAGE_NAME=${BASH_REMATCH[1]}
VERSION=${BASH_REMATCH[2]}
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
else
echo "Commit message does not match the required format."
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.VERSION }}
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}