-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
70 lines (70 loc) · 2.71 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: 'Quinntainer'
author: Casey Lee
description: 'Deploy containers to AWS'
branding:
icon: zap
color: blue
inputs:
aws-region:
description: 'AWS Region, e.g. us-east-2'
required: true
role-to-assume:
description: 'ARN of IAM Role to assume via GHA OIDC'
required: true
port:
description: 'Port listening in container'
required: true
cpu:
description: 'CPU to allocate to container'
default: 1024
memory:
description: 'Memory to allocate to container'
default: 2048
docker-build-context:
description: 'Path to docker build context'
default: '.'
dockerfile:
description: 'Path to Dockerfile'
default: 'Dockerfile'
outputs:
aws-account-id:
description: 'The AWS account ID for the provided credentials'
registry:
description: 'The URI of the ECR registry i.e. aws_account_id.dkr.ecr.region.amazonaws.com. If multiple registries are provided as inputs, this output will not be set.'
runs:
using: 'composite'
steps:
- name: Git clone the repository
uses: actions/checkout@v2
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{inputs.role-to-assume}}
aws-region: ${{inputs.aws-region}}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Setup ECR
uses: aws-actions/aws-cloudformation-github-deploy@v1
with:
name: quinntainer-repo-${{ github.repository_owner }}-${{ github.event.repository.name }}
template: ${{ github.action_path }}/cfn-repo.yaml
parameter-overrides: "GitHubOrg=${{ github.repository_owner }},RepositoryName=${{ github.event.repository.name }}"
no-fail-on-empty-changeset: "1"
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ github.repository }}
IMAGE_TAG: ${{ github.sha }}
shell: bash
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f ${{ inputs.dockerfile }} ${{ inputs.docker-build-context }}
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Setup App Runner
uses: aws-actions/aws-cloudformation-github-deploy@v1
with:
name: quinntainer-app-${{ github.repository_owner }}-${{ github.event.repository.name }}
template: ${{ github.action_path }}/cfn-app-runner.yaml
parameter-overrides: "GitHubOrg=${{ github.repository_owner }},RepositoryName=${{ github.event.repository.name }},ImageTag=${{ github.sha }},Port=${{ inputs.port }},Cpu=${{ inputs.cpu }},Memory=${{ inputs.memory }}"
no-fail-on-empty-changeset: "1"
capabilities: "CAPABILITY_NAMED_IAM"