Skip to content

Commit

Permalink
use environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-farooq committed Sep 20, 2024
1 parent 93c4e20 commit 809a05c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 33 deletions.
35 changes: 3 additions & 32 deletions .github/workflows/ecr-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,6 @@
name: Docker image build and publish
on:
push:
# workflow_dispatch:
inputs:
path_to_dockerfile:
description: Path to the dockerfile (default = 'Dockerfile')
default: "gohelloworld/Dockerfile"
type: string
docker_build_dir:
description: Docker build directory (default = '.')
default: "gohelloworld"
type: string
image_tag:
description: Tag to apply to images.
type: string
default: snapshot-artifact
lifecycle_policy_file:
description: Path to the lifecycle policy JSON file (default = 'policy.json')
default: "e2e-test/policy.json"
type: string
github_iam_role:
description: Name of the IAM Role for adding access to ECR repo
default: "GHActions20240920000443762500000001"
type: string
aws_account_id:
description: AWS Account ID
type: string
aws_region:
description: Target AWS Region
default: "us-east-1"
type: string

jobs:
docker:
Expand Down Expand Up @@ -63,7 +34,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: arn:aws:iam::509399598081:role/GHActions20240920000443762500000001
aws-region: ${{ inputs.aws_region }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
Expand All @@ -77,9 +48,9 @@ jobs:
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ env.ECR_REPO_NAME }}
IMAGE_TAG: ${{ inputs.image_tag }}
IMAGE_TAG: ${{ env.IMAGE_TAG }}
run: |
docker build "${{ inputs.docker_build_dir }}" -f "${{ inputs.path_to_dockerfile }}" -t "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
docker build "${{ env.DOCKER_BUILD_DIR }}" -f "${{ env.PATH_TO_DOCKERFILE }}" -t "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
docker push "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
echo "IMAGE $IMAGE_TAG is pushed to $ECR_REGISTRY/$ECR_REPOSITORY"
echo "image_tag=$IMAGE_TAG"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
terraform.tfstate*
.terraform*
planfile

*.swp

0 comments on commit 809a05c

Please sign in to comment.