Skip to content

Merge pull request #4 from StackVista/STAC-0 #13

Merge pull request #4 from StackVista/STAC-0

Merge pull request #4 from StackVista/STAC-0 #13

Workflow file for this run

name: Build and Push Docker Images
on:
push:
branches: [ main, develop ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
env:
REGISTRY: ghcr.io
REPO: stackvista/agent-integrations-finder
IMAGE_NAME: ghcr.io/stackvista/agent-integrations-finder
jobs:
docker-build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/stackvista/agent-integrations-finder
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=,suffix=,format=short
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r build_requirements.txt
- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Create additional tags for releases
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')
run: |
# Get short SHA (8 characters)
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-8)
VERSION_TAG="${{ github.ref_name }}"
echo "Creating additional version tags: $VERSION_TAG"
# Create architecture-specific version tags
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag ghcr.io/stackvista/agent-integrations-finder:$VERSION_TAG-amd64 \
--tag ghcr.io/stackvista/agent-integrations-finder:$VERSION_TAG-arm64 \
--file Dockerfile \
--push \
.
- name: Show image info
run: |
# Get short SHA (8 characters)
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-8)
echo "Built images:"
docker images ghcr.io/stackvista/agent-integrations-finder || true
echo ""
echo "Available tags:"
echo "- ghcr.io/stackvista/agent-integrations-finder:$SHORT_SHA"
echo "- ghcr.io/stackvista/agent-integrations-finder:$SHORT_SHA-amd64"
echo "- ghcr.io/stackvista/agent-integrations-finder:$SHORT_SHA-arm64"
if [[ "${{ github.ref_name }}" != "${{ github.sha }}" ]]; then
echo "- ghcr.io/stackvista/agent-integrations-finder:${{ github.ref_name }}"
echo "- ghcr.io/stackvista/agent-integrations-finder:${{ github.ref_name }}-amd64"
echo "- ghcr.io/stackvista/agent-integrations-finder:${{ github.ref_name }}-arm64"
fi