Skip to content

Commit

Permalink
[CI] Syncing automation from master
Browse files Browse the repository at this point in the history
  • Loading branch information
Bender committed Dec 11, 2020
1 parent 34fc99e commit 32aec4f
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/del-env.yml
Original file line number Diff line number Diff line change
@@ -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
82 changes: 82 additions & 0 deletions .github/workflows/int-image.yml
Original file line number Diff line number Diff line change
@@ -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 }}
32 changes: 32 additions & 0 deletions integration/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -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:
23 changes: 23 additions & 0 deletions integration/terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 32aec4f

Please sign in to comment.