From 809a05c1d99e3e99677d7687e31f3f560374c1a3 Mon Sep 17 00:00:00 2001 From: Omar Farooq Date: Fri, 20 Sep 2024 02:27:40 +0100 Subject: [PATCH] use environment variables --- .github/workflows/ecr-deploy.yaml | 35 +++---------------------------- .gitignore | 2 +- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ecr-deploy.yaml b/.github/workflows/ecr-deploy.yaml index e60472b..f919d48 100644 --- a/.github/workflows/ecr-deploy.yaml +++ b/.github/workflows/ecr-deploy.yaml @@ -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: @@ -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 @@ -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" diff --git a/.gitignore b/.gitignore index 426fa88..806aedf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ terraform.tfstate* .terraform* planfile - +*.swp