Skip to content

♻️ Renew Dockerfile (2) #7

♻️ Renew Dockerfile (2)

♻️ Renew Dockerfile (2) #7

Workflow file for this run

name: Build and push container image
on:
push:
branches: [main]
tags:
- v**
pull_request:
branches: [main]
env:
IMAGE_BASENAME: k8s-sidecar-injector
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Required for docker/build-push-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/#-action@v3
with:
registry: ${{ vars.ACR_LOGIN_SERVER }}
username: ${{ vars.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Determine Image Tags
id: tags
uses: docker/metadata-action@v5
with:
images: ${{ vars.ACR_LOGIN_SERVER }}/${{ env.IMAGE_BASENAME }}
sep-tags: ','
flavor: |
latest=false
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,enable=${{ github.event_name == 'push' }},prefix=${{ github.ref_name }}-${{ github.run_number }}-
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and Push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.tags.outputs.tags }}
labels: ${{ steps.tags.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BRANCH=${{ github.head_ref }}
COMMIT=${{ github.sha }}
VERSION=${{ steps.tags.outputs.version }}