feat: use shorter names for image tag (#2218) #2
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 to AWS | |
on: | |
workflow_dispatch: | |
inputs: | |
name: | |
description: "Manual workflow name" | |
required: true | |
push: | |
branches: | |
- main | |
env: | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
IMAGE_NAME: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/convoy-rolling-updates | |
jobs: | |
build_ui: | |
name: Build UI | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build Artifact | |
run: "make ui_install type=ce" | |
- name: Archive Build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist-without-markdown | |
path: | | |
web/ui/dashboard/dist | |
!web/ui/dashboard/dist/**/*.md | |
build-and-push-arch: | |
runs-on: ubuntu-latest | |
needs: [build_ui] | |
strategy: | |
matrix: | |
include: | |
- arch: amd64 | |
platform: linux/amd64 | |
dockerfile: release.Dockerfile | |
- arch: arm64 | |
platform: linux/arm64 | |
dockerfile: release.Dockerfile | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set short hash | |
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Download Build Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist-without-markdown | |
path: api/ui/build | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.22 | |
- name: Get and verify dependencies | |
run: go mod tidy && go mod download && go mod verify | |
- name: Go vet | |
run: go vet ./... | |
- name: Build app to make sure there are zero issues | |
run: | | |
export CGO_ENABLED=0 | |
export GOOS=linux | |
export GOARCH=${{ matrix.arch }} | |
go build -o convoy ./cmd | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build and push arch specific images | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ${{ matrix.dockerfile }} | |
platforms: ${{ matrix.platform }} | |
push: true | |
tags: | | |
${{ env.IMAGE_NAME }}:${{ env.SHORT_SHA }}-${{ matrix.arch }} | |
build-args: | | |
ARCH=${{ matrix.arch }} | |
build-and-push-default: | |
runs-on: ubuntu-latest | |
needs: [build-and-push-arch] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set short hash | |
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Create and push manifest for version | |
run: | | |
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ env.SHORT_SHA }} \ | |
${{ env.IMAGE_NAME }}:${{ env.SHORT_SHA }}-amd64 \ | |
${{ env.IMAGE_NAME }}:${{ env.SHORT_SHA }}-arm64 |