Merge pull request #134 from alphagov/LIME-700-DL-TabTitleTest #71
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Development Docker build, ECR push, template copy to S3 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
dockerBuildAndPush: | |
name: Docker build and push | |
runs-on: ubuntu-latest | |
env: | |
AWS_REGION: eu-west-2 | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: "0" | |
- name: Set up AWS creds | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: ${{ secrets.AWS_DL_DEV_ROLE_ARN }} | |
aws-region: eu-west-2 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
DEV_ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
DEV_ECR_REPOSITORY: ${{ secrets.DEV_ECR_REPOSITORY }} | |
run: | | |
cd ${GITHUB_WORKSPACE} || exit 1 | |
docker build -t $DEV_ECR_REGISTRY/$DEV_ECR_REPOSITORY:$GITHUB_SHA . | |
docker push $DEV_ECR_REGISTRY/$DEV_ECR_REPOSITORY:$GITHUB_SHA | |
- name: SAM Validate | |
run: sam validate --region ${{ env.AWS_REGION }} -t deploy/template.yaml | |
- name: Update SAM template with ECR image | |
env: | |
DEV_ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
DEV_ECR_REPOSITORY: ${{ secrets.DEV_ECR_REPOSITORY }} | |
run: | | |
cd ${GITHUB_WORKSPACE}/deploy || exit 1 | |
sed -i "s|CONTAINER-IMAGE-PLACEHOLDER|$DEV_ECR_REGISTRY/$DEV_ECR_REPOSITORY:$GITHUB_SHA|" template.yaml | |
- name: Create template.yaml and sha zip file | |
run: | | |
cd ${GITHUB_WORKSPACE}/deploy || exit 1 | |
sam build | |
mv .aws-sam/build/template.yaml cf-template.yaml | |
zip template.zip cf-template.yaml | |
- name: Upload CloudFormation artifacts to S3 | |
env: | |
DEV_ARTIFACT_BUCKET: ${{ secrets.DEV_ARTIFACT_BUCKET }} | |
run: | | |
cd ${GITHUB_WORKSPACE}/deploy || exit 1 | |
aws s3 cp template.zip "s3://$DEV_ARTIFACT_BUCKET/template.zip" --metadata "repository=$GITHUB_REPOSITORY,commitsha=$GITHUB_SHA" |