Skip to content

feat: Add GitHub Actions workflow for building and pushing Docker images #1

feat: Add GitHub Actions workflow for building and pushing Docker images

feat: Add GitHub Actions workflow for building and pushing Docker images #1

name: Build and Push Docker image
on:
push:
branches: [main, release-test]
tags: ['v*']
jobs:
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 Amazon ECR Public
uses: docker/login-action@v3
with:
registry: public.ecr.aws
username: ${{ secrets.AWS_ACCESS_KEY }}
password: ${{ secrets.AWS_SECRET }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
public.ecr.aws/r4g1k2s3/vcon-dev/vcon-admin
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{branch}}-
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}