From 88f228fe6e3a689bfef7e0746c2d377deab16beb Mon Sep 17 00:00:00 2001 From: Dimitris Kargatzis Date: Sat, 9 Mar 2024 05:53:54 +0200 Subject: [PATCH] refactor: Clean unnecessary / duplicate folder Signed-off-by: Dimitris Kargatzis --- .github/actions/aws-configure/action.yaml | 61 ------------------- .../actions/docker-build-and-push/README.md | 51 ---------------- .../actions/docker-build-and-push/action.yaml | 39 ------------ .../helm-install-local-chart/action.yaml | 59 ------------------ .../helm-install-local-chart/metadata.json | 7 --- ...uild-push-and-deploy-to-eks-with-helm.yaml | 2 +- .../aws-configure/metadata.json | 0 .../docker-build-and-push/metadata.json | 2 +- .../helm-install-local-chart}/metadata.json | 0 9 files changed, 2 insertions(+), 219 deletions(-) delete mode 100644 .github/actions/aws-configure/action.yaml delete mode 100644 .github/actions/docker-build-and-push/README.md delete mode 100644 .github/actions/docker-build-and-push/action.yaml delete mode 100644 .github/actions/helm-install-local-chart/action.yaml delete mode 100644 .github/actions/helm-install-local-chart/metadata.json rename {.github/actions => ci-cd-and-automation/github/composite-actions}/aws-configure/metadata.json (100%) rename {.github/actions/docker-build-and-push => ci-cd-and-automation/github/composite-actions/helm-install-local-chart}/metadata.json (100%) diff --git a/.github/actions/aws-configure/action.yaml b/.github/actions/aws-configure/action.yaml deleted file mode 100644 index 0087e04..0000000 --- a/.github/actions/aws-configure/action.yaml +++ /dev/null @@ -1,61 +0,0 @@ -name: 'Configure AWS' -description: 'Configures AWS credentials, authenticates to ECR and creates AWS profile' - -inputs: - aws-access-key-id: - description: 'AWS Access Key ID' - required: true - aws-secret-access-key: - description: 'AWS Secret Access Key' - required: true - aws-region: - description: 'The region on AWS to host the workspace resources in' - required: true - eks-cluster: - description: 'The name of the EKS cluster on AWS' - required: true -outputs: - registry-url: - description: 'The URL of the Container Registry in AWS' - value: ${{ steps.construct-registry-url.outputs.registry-url }} - -runs: - using: "composite" - steps: - # Configure AWS credentials - - name: 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 }} - - # 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 }} - - # 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 }} - - # Construct the ECR registry URL - - name: Construct ECR Registry URL - id: construct-registry-url - run: |- - registry_url="${{ inputs.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" - - # Update kube-config for EKS cluster - - name: Config kubectl - id: kube-config - run: | - # Update kube-config for EKS cluster - aws eks --region ${{ inputs.aws-region }} update-kubeconfig --name ${{ inputs.eks-cluster }} diff --git a/.github/actions/docker-build-and-push/README.md b/.github/actions/docker-build-and-push/README.md deleted file mode 100644 index 480b995..0000000 --- a/.github/actions/docker-build-and-push/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# Build and Push Docker Image Composite Action - -This composite GitHub Action builds a Docker image from your repository and pushes it to any specified container -registry. It is versatile and can be used with various container registries like Docker Hub, Google Container Registry -(GCR), Azure Container Registry (ACR), or AWS Elastic Container Registry (ECR), assuming that authentication to the -registry is handled separately. - -## Inputs - -- `image-name`: The name of the Docker image to build and push. This is a required input. -- `registry-url`: The URL of the container registry where the image will be pushed. This is a required input. - -## Outputs - -- `image-tag`: The tag of the Docker image that was pushed to the container registry. - -## Example Usage - -Include this action in your workflow `.yaml` file by adding a step like the one shown below: - -```yaml -steps: - # ... - # Other steps such as setting up the job, checking out the code, and logging into the registry - # ... - - - name: Build and push Docker image to a registry - uses: warestack/blueprints/ci-cd-and-automation/github/composite-actions/action.yaml@main - with: - image-name: 'sample-app' - registry-url: ${{ steps..outputs.registry }} -``` - -Replace the `image-name` and `registry-url` with your image's name and your registry's URL, respectively. For AWS ECR, -this will typically be the output from the amazon-ecr-login action. For other registries, it will be the step that -performs the authentication and sets the registry URL. - -## Notes - -- The Docker build context is set to the root of your repository. -- The tag for the image is automatically generated using the short SHA of the commit and the current date and time. -- Ensure Docker is available in the runner environment where this action will be used. -- Authentication to the Docker registry should be handled in a step prior to using this action. For AWS ECR, use the - `aws-actions/amazon-ecr-login` action. For other registries, follow the registry's recommended login procedure. - -For a real-world usage example, see the [`example_workflow.yaml`](examples/example_workflow.yaml) in the examples -directory. - -## Questions & Contributions - -If you have any questions or wish to contribute, please open an issue or submit a pull request. diff --git a/.github/actions/docker-build-and-push/action.yaml b/.github/actions/docker-build-and-push/action.yaml deleted file mode 100644 index 44abeee..0000000 --- a/.github/actions/docker-build-and-push/action.yaml +++ /dev/null @@ -1,39 +0,0 @@ -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: - description: 'URL of the container registry' - required: true -outputs: - image-tag: - description: 'The tag of the image pushed to the container registry' - value: ${{ steps.push.outputs.image-tag }} - -runs: - using: "composite" - steps: - # Generate the tag to be used while building the Docker image - - name: Generate tag - id: tag - run: |- - 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 - echo "image_tag=${image_tag}" >> $GITHUB_ENV - echo "::set-output name=image-tag::${image_tag}" - - # Build the Docker image - - name: Build Docker image - run: docker build --tag ${{ env.image_tag }} . - - # Push the Docker image to the registry - - name: Push Docker image to registry - id: push - run: |- - docker push ${{ env.image_tag }} diff --git a/.github/actions/helm-install-local-chart/action.yaml b/.github/actions/helm-install-local-chart/action.yaml deleted file mode 100644 index 3dcfe4f..0000000 --- a/.github/actions/helm-install-local-chart/action.yaml +++ /dev/null @@ -1,59 +0,0 @@ -name: 'Install Helm releases' -description: 'Deploy a service using Warestack and Helm package manager' -inputs: - environment: - description: "The value can be development, staging, production, etc." - required: true - release_name: - description: 'Release name to be used for the helm releases and Container Repository' - required: true - namespace: - description: 'The organization to be used for the namespace in helm install' - required: true - registry_url: - description: 'URL of the container registry' - required: true - image_name: - description: 'Name of the image to build and push' - required: true - image_tag: - description: 'The tag of the image pushed to the container registry' - required: true - public_url: - description: 'Public URL to used for exposing the service' - required: true - port: - description: 'Port to used for exposing the pod in Kube' - required: true - helm_path: - description: 'Path to the Helm chart' - required: true - -runs: - using: "composite" - steps: - # Install or Upgrade the Helm release - - name: Install or upgrade helm release - env: - ENVIRONMENT: ${{ github.event.inputs.environment }} - RELEASE_NAME: ${{ inputs.release_name }} - NAMESPACE: ${{ inputs.namespace }} - IMAGE_REPO: ${{ inputs.registry_url }}/${{ inputs.image_name }} - IMAGE_TAG: ${{ inputs.image_tag }} - PUBLIC_URL: ${{ inputs.public_url }} - PORT: ${{ inputs.port }} - HELM_PATH: ${{ inputs.helm_path }} - run: |- - helm upgrade ${{ env.RELEASE_NAME }} ${{ env.HELM_PATH }} --namespace ${{ env.NAMESPACE }} --create-namespace --wait \ - --values ${{ env.HELM_PATH }}/values-${{ env.ENVIRONMENT }}.yaml \ - --set image.repository=$IMAGE_REPO \ - --set image.tag=$IMAGE_TAG \ - --set cert.tls.secretName=$RELEASE_NAME \ - --set cert.commonName=$PUBLIC_URL \ - --set cert.dnsNames.hosts={$PUBLIC_URL} \ - --set service.port=$PORT \ - --set ingress.hosts[0].host=$PUBLIC_URL \ - --set ingress.tls[0].secretName=$RELEASE_NAME \ - --set ingress.tls[0].hosts={$PUBLIC_URL} \ - --install - shell: bash diff --git a/.github/actions/helm-install-local-chart/metadata.json b/.github/actions/helm-install-local-chart/metadata.json deleted file mode 100644 index ac84c97..0000000 --- a/.github/actions/helm-install-local-chart/metadata.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "Docker Build and Push", - "description": "A GitHub Composite Action that builds a Docker image from your application and pushes it to a Docker registry.", - "type": "built-in-component", - "version": "1.0.0", - "tags": ["Docker", "GitHub Actions", "CI/CD", "Composite Action", "Deployment"] -} diff --git a/.github/workflows/aws-build-push-and-deploy-to-eks-with-helm.yaml b/.github/workflows/aws-build-push-and-deploy-to-eks-with-helm.yaml index 8873f0c..c900bf5 100644 --- a/.github/workflows/aws-build-push-and-deploy-to-eks-with-helm.yaml +++ b/.github/workflows/aws-build-push-and-deploy-to-eks-with-helm.yaml @@ -46,7 +46,7 @@ jobs: deploy: name: Setup, Build and Publish Docker image to ECR, and Deploy to EKS using Helm runs-on: ubuntu-latest - environment: ${{ inputs.environment }} +# environment: ${{ inputs.environment }} env: BRANCH: ${{ github.head_ref || github.ref_name }} ENVIRONMENT: ${{ inputs.environment }} diff --git a/.github/actions/aws-configure/metadata.json b/ci-cd-and-automation/github/composite-actions/aws-configure/metadata.json similarity index 100% rename from .github/actions/aws-configure/metadata.json rename to ci-cd-and-automation/github/composite-actions/aws-configure/metadata.json diff --git a/ci-cd-and-automation/github/composite-actions/docker-build-and-push/metadata.json b/ci-cd-and-automation/github/composite-actions/docker-build-and-push/metadata.json index 4535fa1..ac84c97 100644 --- a/ci-cd-and-automation/github/composite-actions/docker-build-and-push/metadata.json +++ b/ci-cd-and-automation/github/composite-actions/docker-build-and-push/metadata.json @@ -1,7 +1,7 @@ { "name": "Docker Build and Push", "description": "A GitHub Composite Action that builds a Docker image from your application and pushes it to a Docker registry.", - "type": "blueprint", + "type": "built-in-component", "version": "1.0.0", "tags": ["Docker", "GitHub Actions", "CI/CD", "Composite Action", "Deployment"] } diff --git a/.github/actions/docker-build-and-push/metadata.json b/ci-cd-and-automation/github/composite-actions/helm-install-local-chart/metadata.json similarity index 100% rename from .github/actions/docker-build-and-push/metadata.json rename to ci-cd-and-automation/github/composite-actions/helm-install-local-chart/metadata.json