From 0bcb216d9d19d29e28709deddf34f890ae17fa31 Mon Sep 17 00:00:00 2001 From: Jakob Nohe Date: Mon, 19 Feb 2024 12:47:49 +0100 Subject: [PATCH] initial commit --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++++++ Dockerfile | 31 +++++++++++++++++++++++++++++++ action.yml | 14 ++++++++++++++ entrypoint.sh | 3 +++ 4 files changed, 80 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 Dockerfile create mode 100644 action.yml create mode 100755 entrypoint.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fda16ee --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: ci +on: + push: + branches: + - "*" + tags: + - "*" + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Packages + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ghcr.io/meisterplan/actions-k8s-deploy/actions-k8s-deploy:${{ github.ref_name }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..43cf0d6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM amazon/aws-cli:2.13.26 + +# Install common cli tools +RUN yum install -y curl make grep git tar zsh && yum clean all && rm -rf /var/cache/yum + +# Install latest jq & yq version +RUN curl -Lo /usr/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && chmod +x /usr/bin/jq +RUN curl -Lo /usr/bin/yq https://github.com/mikefarah/yq/releases/download/v4.34.1/yq_linux_amd64 && chmod +x /usr/bin/yq + + +# Install aws-iam-authenticator for k8s +ENV AWS_IAM_AUTH_VERSION=0.6.11 +RUN curl -Lo /usr/bin/aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v${AWS_IAM_AUTH_VERSION}/aws-iam-authenticator_${AWS_IAM_AUTH_VERSION}_linux_amd64 && \ + chmod +x /usr/bin/aws-iam-authenticator + +# Install kubectl +ENV KUBECTL_VERSION=1.28.3 +RUN curl -Lo /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \ + chmod +x /usr/bin/kubectl + +# Install helm +ENV HELM_VERSION=3.13.1 +RUN cd /tmp && \ + curl -Lo helm.tgz https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz && \ + tar xvfz helm.tgz && \ + mv linux-amd64/helm /usr/bin/helm && \ + rm -rf /tmp/* + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..20bc886 --- /dev/null +++ b/action.yml @@ -0,0 +1,14 @@ +name: 'Kubernetes Deploy' +description: 'Deploy things to Kubernetes using a custom command' +inputs: + command: + description: 'Command that should be executed' + required: true + working-directory: + description: 'Directory where the command should be executed' + default: "." +runs: + using: 'docker' + image: 'docker://ghcr.io/meisterplan/actions-k8s-deploy/actions-k8s-deploy@master' + args: + - "cd ${{ inputs.working-directory }} && ${{ inputs.command }} && echo \"Hello World\"" diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..783e0e9 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +/bin/bash -c "$@"