chore: heygermany customer project
This commit is contained in:
67
.github/actions/ecr-build-and-push/action.yml
vendored
Normal file
67
.github/actions/ecr-build-and-push/action.yml
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
name: Build and Push to ECR
|
||||
description: Fully prepares, builds, and pushes a Docker image to AWS ECR.
|
||||
|
||||
inputs:
|
||||
dockerfile:
|
||||
description: 'Path to Dockerfile'
|
||||
required: true
|
||||
image-name:
|
||||
description: 'ECR repo name (e.g. api or dbmigrate)'
|
||||
required: true
|
||||
aws-region:
|
||||
description: 'AWS region'
|
||||
required: true
|
||||
aws-access-key-id:
|
||||
description: 'AWS Access Key ID'
|
||||
required: true
|
||||
aws-secret-access-key:
|
||||
description: 'AWS Secret Access Key'
|
||||
required: true
|
||||
github-sha:
|
||||
description: 'Commit SHA to tag the image with'
|
||||
default: ${{ github.sha }}
|
||||
|
||||
outputs:
|
||||
ecr_image:
|
||||
description: 'Final ECR image URI'
|
||||
value: ${{ steps.build.outputs.ecr_image }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Setup AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-access-key-id: ${{ inputs.aws-access-key-id }}
|
||||
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
|
||||
aws-region: ${{ inputs.aws-region }}
|
||||
|
||||
- name: Login to Amazon ECR
|
||||
id: ecr-login
|
||||
uses: aws-actions/amazon-ecr-login@v1
|
||||
|
||||
- name: Download generated files
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: generated-code
|
||||
path: ${{ github.workspace }}
|
||||
|
||||
- name: List generated files
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Listing .gen.ts and .gen.d.ts files:"
|
||||
pwd
|
||||
find . -name "*.gen.ts" -o -name "*.gen.d.ts"
|
||||
|
||||
- name: Build and Push Docker Image
|
||||
shell: bash
|
||||
id: build
|
||||
run: |
|
||||
IMAGE_URI=${{ steps.ecr-login.outputs.registry }}/${{ inputs.image-name }}:${{ inputs.github-sha }}
|
||||
docker build -t $IMAGE_URI -f ${{ inputs.dockerfile }} .
|
||||
docker tag $IMAGE_URI ${{ steps.ecr-login.outputs.registry }}/${{ inputs.image-name }}:latest
|
||||
docker push $IMAGE_URI
|
||||
docker push ${{ steps.ecr-login.outputs.registry }}/${{ inputs.image-name }}:latest
|
||||
# Safe base64 encode and output
|
||||
IMAGE_URI_BASE64=$(echo -n "$IMAGE_URI" | base64 | tr -d '\n')
|
||||
echo "ecr_image=$IMAGE_URI_BASE64" >> $GITHUB_OUTPUT
|
||||
Reference in New Issue
Block a user