Skip to content

Commit

Permalink
fix: Align naming convention in composite actions
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitris Kargatzis <dkargatzis@gmail.com>
  • Loading branch information
dkargatzis committed Mar 9, 2024
1 parent 9b2b179 commit 7e3fb9c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 44 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/aws-build-push-and-deploy-to-eks-with-helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,18 @@ jobs:
deploy:
name: Setup, Build and Publish Docker image to ECR, and Deploy to EKS using Helm
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
ENVIRONMENT: ${{ github.event.inputs.environment }}
REGION: ${{ github.event.inputs.region }}
IMAGE_NAME: ${{ github.event.inputs.image_name }}
EKS_CLUSTER: ${{ github.event.inputs.eks_cluster }}
NAMESPACE: ${{ github.event.inputs.namespace }}
RELEASE_NAME: ${{ github.event.inputs.release_name }}
PUBLIC_URL: ${{ github.event.inputs.public_url }}
PORT: ${{ github.event.inputs.port }}
HELM_PATH: ${{ github.event.inputs.helm_path }}
ENVIRONMENT: ${{ inputs.environment }}
REGION: ${{ inputs.region }}
IMAGE_NAME: ${{ inputs.image_name }}
EKS_CLUSTER: ${{ inputs.eks_cluster }}
NAMESPACE: ${{ inputs.namespace }}
RELEASE_NAME: ${{ inputs.release_name }}
PUBLIC_URL: ${{ inputs.public_url }}
PORT: ${{ inputs.port }}
HELM_PATH: ${{ inputs.helm_path }}
JOB_STATUS: succeeded

# Add "id-token" with the intended permissions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,62 @@ name: 'Configure AWS'
description: 'Configures AWS credentials, authenticates to ECR and creates AWS profile'

inputs:
aws-access-key-id:
aws_access_key_id:
description: 'AWS Access Key ID'
required: true
aws-secret-access-key:
aws_secret_access_key:
description: 'AWS Secret Access Key'
required: true
aws-region:
aws_region:
description: 'The region on AWS to host the workspace resources in'
required: true
eks-cluster:
eks_cluster:
description: 'The name of the EKS cluster on AWS'
required: true
outputs:
registry-url:
registry_url:
description: 'The URL of the Container Registry in AWS'
value: ${{ steps.construct-registry-url.outputs.registry-url }}
value: ${{ steps.construct_registry_url.outputs.registry_url }}

runs:
using: "composite"
steps:
# Configure AWS credentials
- name: Configure AWS credentials
id: configure_aws_credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: ${{ inputs.aws-region }}
aws-access-key-id: ${{ inputs.aws_access_key_id }}
aws-secret-access-key: ${{ inputs.aws_secret_access_key }}
aws-region: ${{ inputs.aws_region }}

# Configure authentication to ECR
- name: Authenticate to ECR
id: ecr
uses: jwalton/gh-ecr-login@v1
with:
access-key-id: ${{ inputs.aws-access-key-id }}
secret-access-key: ${{ inputs.aws-secret-access-key }}
region: ${{ inputs.aws-region }}
access-key-id: ${{ inputs.aws_access_key_id }}
secret-access-key: ${{ inputs.aws_secret_access_key }}
region: ${{ inputs.aws_region }}

# Create profile for AWS interface
- name: Create the default profile for EKS/ECR interface
run: |-
aws configure set aws_access_key_id ${{ inputs.aws-access-key-id }}
aws configure set aws_secret_access_key ${{ inputs.aws-secret-access-key }}
aws configure set aws_access_key_id ${{ inputs.aws_access_key_id }}
aws configure set aws_secret_access_key ${{ inputs.aws_secret_access_key }}
shell: bash

# Construct the ECR registry URL
- name: Construct ECR Registry URL
id: construct-registry-url
id: construct_registry_url
run: |-
registry_url="${{ inputs.aws-account-id }}.dkr.ecr.${{ inputs.aws-region }}.amazonaws.com"
registry_url="${{ steps.configure_aws_credentials.outputs.aws-account-id }}.dkr.ecr.${{ inputs.aws_region }}.amazonaws.com"
echo "registry_url=$registry_url" >> $GITHUB_ENV
echo "::set-output name=registry-url::$registry_url"
echo "::set-output name=registry_url::$registry_url"
shell: bash

# Update kube-config for EKS cluster
- name: Config kubectl
id: kube-config
run: |
run: |-
# Update kube-config for EKS cluster
aws eks --region ${{ inputs.aws-region }} update-kubeconfig --name ${{ inputs.eks-cluster }}
aws eks --region ${{ inputs.aws_region }} update-kubeconfig --name ${{ inputs.eks_cluster }}
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ name: 'Build and push Docker image'
description: 'Build and push Docker image to a container registry, assuming authentication is handled separately'

inputs:
image-name:
description: 'Name of the image to build and push'
required: true
registry-url:
registry_url:
description: 'URL of the container registry'
required: true
image_name:
description: 'Name of the image to build and push'
required: true
outputs:
image-tag:
image_tag:
description: 'The tag of the image pushed to the container registry'
value: ${{ steps.push.outputs.image-tag }}
value: ${{ steps.tag.outputs.image_tag }}

runs:
using: "composite"
Expand All @@ -23,21 +23,18 @@ runs:
github_sha="${{ github.sha }}"
version_date=$(date +'%Y%m%d%H%M%S')
version_tag="${github_sha::7}-${version_date}"
image_tag="${{ inputs.registry-url }}/${{ inputs.image-name }}:${version_tag}"
# Set the environment variables
image_tag="${{ inputs.registry_url }}/${{ inputs.image_name }}:${version_tag}"
echo "image_tag=${image_tag}" >> $GITHUB_ENV
echo "::set-output name=image-tag::${image_tag}"
echo "::set-output name=image_tag::${image_tag}"
shell: bash

# Build the Docker image
- name: Build Docker image
run: |-
docker build --tag ${{ env.image_tag }} .
run: docker build --tag ${{ env.image_tag }} .
shell: bash

# Push the Docker image to the registry
- name: Push Docker image to registry
id: push
run: |-
docker push ${{ env.image_tag }}
run: docker push ${{ env.image_tag }}
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ runs:
# Install or Upgrade the Helm release
- name: Install or upgrade helm release
env:
ENVIRONMENT: ${{ github.event.inputs.environment }}
ENVIRONMENT: ${{ inputs.environment }}
RELEASE_NAME: ${{ inputs.release_name }}
NAMESPACE: ${{ inputs.namespace }}
IMAGE_REPO: ${{ inputs.registry_url }}/${{ inputs.image_name }}
Expand Down

0 comments on commit 7e3fb9c

Please sign in to comment.