Skip to content

Docker image build and publish #15

Docker image build and publish

Docker image build and publish #15

Workflow file for this run

name: Docker image build and publish
on:
workflow_dispatch:
inputs:
image_name:
description: Name of the image.
type: string
default: rockset/webhook
image_tag:
description: Tag to apply to images.
type: string
default: latest
region:
description: AWS region.
type: string
default: us-east-1
account:
description: AWS account.
type: string
default: 216690786812
jobs:
docker:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
outputs:
image_tag: ${{ steps.build-publish.outputs.image_tag }}
full_image: ${{ steps.build-publish.outputs.full_image }}
steps:
- uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::216690786812:role/github-actions
aws-region: "us-east-1"
- name: Build image
id: build
shell: bash
env:
IMAGE_NAME: ${{ inputs.image_name }}
IMAGE_TAG: ${{ inputs.image_tag }}
run: |
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .
- name: Login to Amazon ECR (public)
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
aws-region: ${{ inputs.region }}
registries: ${{ inputs.account }}
mask-password: "true"
- name: Tag, and push image to Amazon ECR (public)
id: publish-public
shell: bash
env:
ECR_REGISTRY: ${{ steps.login-ecr-public.outputs.registry }}
IMAGE_NAME: ${{ inputs.image_name }}
IMAGE_TAG: ${{ inputs.image_tag }}
run: |
docker tag ${IMAGE_NAME}:${IMAGE_TAG} public.ecr.aws/r8t4f8i3/${IMAGE_NAME}:${IMAGE_TAG}
docker push public.ecr.aws/r8t4f8i3/${IMAGE_NAME}:${IMAGE_TAG}
- name: Login to Amazon ECR (private)
id: login-ecr-private
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: private
aws-region: ${{ inputs.region }}
registries: ${{ inputs.account }}
mask-password: "true"
- name: Tag, and push image to Amazon ECR (private)
id: publish-private
shell: bash
env:
ECR_REGISTRY: ${{ steps.login-ecr-private.outputs.registry }}
IMAGE_NAME: ${{ inputs.image_name }}
IMAGE_TAG: ${{ inputs.image_tag }}
run: |
docker tag "${IMAGE_NAME}:${IMAGE_TAG}" "${ECR_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
docker push "${ECR_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"