From 32aec4f0b0ee7982da1ccac6231a502bdeffad0e Mon Sep 17 00:00:00 2001 From: Bender Date: Fri, 11 Dec 2020 14:45:41 +0000 Subject: [PATCH] [CI] Syncing automation from master --- .github/workflows/del-env.yml | 21 ++++++++ .github/workflows/int-image.yml | 82 ++++++++++++++++++++++++++++++++ integration/image/Dockerfile | 32 +++++++++++++ integration/terraform/outputs.tf | 23 +++++++++ 4 files changed, 158 insertions(+) create mode 100644 .github/workflows/del-env.yml create mode 100644 .github/workflows/int-image.yml create mode 100644 integration/image/Dockerfile create mode 100644 integration/terraform/outputs.tf diff --git a/.github/workflows/del-env.yml b/.github/workflows/del-env.yml new file mode 100644 index 00000000000..c99ba6f9b05 --- /dev/null +++ b/.github/workflows/del-env.yml @@ -0,0 +1,21 @@ +# Generated by: wf-gen from tyk-ci +# Generated on: Fri 11 Dec 00:35:46 IST 2020 + + +name: Retiring dev env + +on: + delete: + branches: + - feature/* + - integration/* + +jobs: + retire: + runs-on: ubuntu-latest + + steps: + - name: Tell gromit about deleted branch + run: | + curl -fsSL -H "Authorization: ${{secrets.GROMIT_TOKEN}}" "https://domu-kun.cloud.tyk.io/gromit/env/${GITHUB_REF##*/}" \ + -X DELETE diff --git a/.github/workflows/int-image.yml b/.github/workflows/int-image.yml new file mode 100644 index 00000000000..2c8e06db250 --- /dev/null +++ b/.github/workflows/int-image.yml @@ -0,0 +1,82 @@ +# Generated by: pr.zsh from tyk-ci/wf-gen +# Generated on: Fri 11 Dec 00:35:46 IST 2020 + +name: tyk image + +on: + push: + branches: + - master + - integration/* + - feature/* + - release-** + +jobs: + tyk: + runs-on: ubuntu-latest + container: tykio/tyk-build-env:ga + + steps: + - name: checkout tyk + uses: actions/checkout@v2 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + with: + cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} + terraform_wrapper: false + + - name: Get AWS creds from Terraform remote state + id: aws-creds + run: | + cd integration/terraform + terraform init -input=false -lock=false + terraform refresh + eval $(terraform output -json tyk | jq -r 'to_entries[] | [.key,.value] | join("=")') + region=$(terraform output region | xargs) + [ -z "$key" -o -z "$secret" -o -z "$region" -o -z "$ecr" ] && exit 1 + echo "::set-output name=secret::$secret" + echo "::add-mask::$secret" + echo "::set-output name=key::$key" + echo "::set-output name=ecr::$ecr" + echo "::set-output name=region::$region" + + - name: Configure AWS credentials for use + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ steps.aws-creds.outputs.key }} + aws-secret-access-key: ${{ steps.aws-creds.outputs.secret }} + aws-region: ${{ steps.aws-creds.outputs.region }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build release tarball + run: | + if [ -x bin/integration_build.sh ]; then + SIGNPKGS=0 BUILDPKGS=0 BUILDWEB=0 ARCH=amd64 bin/integration_build.sh + cp tyk-amd64-*.tar.gz integration/image/tyk.tar.gz + fi + + - name: Build, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: tyk + run: | + cd integration/image + IMAGE_TAG="${GITHUB_REF##*/}" + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:latest \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA} \ + . + docker push $ECR_REGISTRY/$ECR_REPOSITORY + + - name: Tell gromit about new build + run: | + curl -fsSL -H "Authorization: ${{secrets.GROMIT_TOKEN}}" 'https://domu-kun.cloud.tyk.io/gromit/newbuild' \ + -X POST -d '{ "repo": "${{ github.repository}}", "ref": "${{ github.ref }}", "sha": "${{ github.sha }}" }' + + - name: Logout of Amazon ECR + if: always() + run: docker logout ${{ steps.login-ecr.outputs.registry }} diff --git a/integration/image/Dockerfile b/integration/image/Dockerfile new file mode 100644 index 00000000000..f7edc79d98c --- /dev/null +++ b/integration/image/Dockerfile @@ -0,0 +1,32 @@ +# Generated on: Fri 11 Dec 00:35:46 IST 2020 + +# Generated by: wf-gen from tyk-ci + +FROM debian:buster-slim + +RUN apt-get update \ + && apt-get dist-upgrade -y --no-install-recommends \ + wget jq curl ca-certificates apt-transport-https gnupg unzip + +RUN apt-get install -y --no-install-recommends \ + build-essential \ + python3-setuptools \ + libpython3.7 \ + python3.7-dev \ + python3-pip \ + && pip3 install protobuf grpcio==1.24.0 \ + && apt-get purge -y build-essential \ + && rm -rf /root/.cache +RUN apt-get autoremove -y + +ADD tyk.tar.gz /opt/tyk + +VOLUME ["/conf"] +WORKDIR /opt/tyk + +ENTRYPOINT ["/opt/tyk/tyk" ] +CMD [ "--conf=/conf/tyk/tyk.conf" ] + +# Local Variables: +# mode: dockerfile +# End: diff --git a/integration/terraform/outputs.tf b/integration/terraform/outputs.tf new file mode 100644 index 00000000000..8a49a4ba610 --- /dev/null +++ b/integration/terraform/outputs.tf @@ -0,0 +1,23 @@ +# Generated by: wf-gen from tyk-ci +# Generated at: Fri 11 Dec 00:35:46 IST 2020 + +data "terraform_remote_state" "integration" { + backend = "remote" + + config = { + organization = "Tyk" + workspaces = { + name = "base-prod" + } + } +} + +output "tyk" { + value = data.terraform_remote_state.integration.outputs.tyk + description = "ECR creds for tyk repo" +} + +output "region" { + value = data.terraform_remote_state.integration.outputs.region + description = "Region in which the env is running" +}