Skip to content

Commit

Permalink
Merge pull request #1 from instructure-bridge/cicd
Browse files Browse the repository at this point in the history
Add CI for eks-auto-drain
  • Loading branch information
psi authored Sep 23, 2020
2 parents 00cf778 + a0e5750 commit 223f13c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build & Publish to S3
on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run SAM build
uses: TractorZoom/sam-cli-action@master
with:
sam_command: "build"
- name: Archive build
uses: montudor/[email protected]
with:
args: zip -qq -r aws-sam.zip README.md .aws-sam
- name: Upload build archive
uses: actions/upload-artifact@v2
with:
name: aws-sam
path: aws-sam.zip
publish-to-s3:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
include:
- region: cmh
aws_region: us-east-2
- region: dub
aws_region: eu-west-1
- region: iad
aws_region: us-east-1
- region: syd
aws_region: ap-southeast-2
steps:
- name: Download build archive
uses: actions/download-artifact@v2
with:
name: aws-sam
- name: Unzip build archive
uses: montudor/[email protected]
with:
args: unzip -qq aws-sam.zip
- name: Publish to S3 (${{ matrix.region }})
uses: TractorZoom/sam-cli-action@master
with:
sam_command: "package --output-template-file packaged.yaml --s3-bucket truss-eks-auto-drain-${{ matrix.region }}"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.TRUSS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.TRUSS_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ matrix.aws_region }}
- name: Extract artifact metadata
id: artifact-metadata
run: |
s3_path=$(grep CodeUri packaged.yaml | cut -d'/' -f4)
echo "::set-output name=s3_path::$s3_path"
echo "Lambda Package S3 Key: $s3_path"
shell: bash
- name: Update current package revision on merge to master
if: github.ref == 'refs/heads/master'
run: |
echo ${{steps.artifact-metadata.outputs.s3_path}} > s3_path.txt
aws s3 cp ./s3_path.txt s3://truss-eks-auto-drain-${{ matrix.region }}/current
env:
AWS_ACCESS_KEY_ID: ${{ secrets.TRUSS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.TRUSS_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ matrix.aws_region }}
outputs:
artifact_s3_path: ${{ steps.artifact-metadata.outputs.s3_path }}
5 changes: 2 additions & 3 deletions template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Metadata:
Description: Drains an EKS Worker Node when invoked by a CloudWatch event matching an Auto Scaling Group instance-terminating lifecycle action
Author: Derek Keightley
SpdxLicenseId: MIT
LicenseUrl: LICENSE
ReadmeUrl: README.md
Labels: ['eks', 'asg', 'lambda', 'kubernetes']
HomePageUrl: https://github.com/dkeightley/eks-auto-drain
Expand All @@ -20,7 +19,7 @@ Resources:
Properties:
CodeUri: src/
Handler: lambda_function.lambda_handler
Runtime: python3.6
Runtime: python3.8
Timeout: 600
Policies:
- Version: '2012-10-17'
Expand Down Expand Up @@ -88,4 +87,4 @@ Outputs:
Fn::GetAtt:
- "LambdaFunctionRole"
- "Arn"
Description: "Lambda IAM Role, to be added to the aws-auth ConfigMap"
Description: "Lambda IAM Role, to be added to the aws-auth ConfigMap"

0 comments on commit 223f13c

Please sign in to comment.