Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: DEVOPS-991: added deployment of docker images to ECR via Github Actions #5

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/deploy.yml
@@ -0,0 +1,40 @@
name: Deploy ScoutSuite Docker Image to ECR
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build_and_push:
name: Build and Push Docker Images to ECR
runs-on: ubuntu-16.04

steps:
- name: Git Checkout
uses: actions/checkout@v2

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: ECR login
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push ScoutSuite image to ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ifit/scoutsuite
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REPOSITORY .
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
19 changes: 16 additions & 3 deletions IFIT.md
@@ -1,8 +1,20 @@
# iFit

See corresponding CloudFormation template for ECR repository information
[![Deployments](https://github.com/ifit/ScoutSuite/workflows/Deploy%20ScoutSuite%20Docker%20Image%20to%20ECR/badge.svg)](https://github.com/ifit/ScoutSuite/actions?query=workflow%3A%22Build%20and%20Push%20Docker%20Images%20to%20ECR%22)

## Build Steps
See corresponding [ScouteSuite CloudFormation template](https://github.com/ifit/the-diagram/blob/master/cloudformation/scout-suite.yml) for ECR repository information

## Deployments

Github Actions build, tag (short `sha1` && `latest`), and push docker images to ECR for every PR/Push to the `master` branch via the [`Deploy ScoutSuite Docker Image to ECR`](../.github/workflows/deploy.yml) workflow using a dedicated [IAM user](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#create-iam-users) with [least priveledge granted](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege) and keeping AWS Access Keys stored as [GitHub Actions secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets).

The ECR LifecyclePolicy for the ScouteSuite Repo only retains 3 docker images. Each time the task runs the `lastest` image will be used.

### RollingBack

To rollback a bad deploy/broken image you can delete the defective image, and ensure that the image in the rpo you wish to be used is tagged as `latest`.

## Manual Build Steps

### Log into ECR

Expand All @@ -21,7 +33,8 @@ See corresponding CloudFormation template for ECR repository information
* `docker push <account_id>.dkr.ecr.<region>.amazonaws.com/scout-suite/scout-suite:latest`

## Changelog

* 2020-09-11
* added deployments of docker images to ECR via Github Actions
* 2020-07-03
* Add ability to push output report to a parameterized S3 bucket (pulled from env var)
* Set mime types on objects pushed to S3
Expand Down