-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (58 loc) · 1.99 KB
/
build_and_deploy.yaml
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
name: Build and Deploy
on: workflow_call
jobs:
deploy-cloudformation:
uses: melanahammel/fire-starter/.github/workflows/deploy_cloudformation.yaml@main
secrets:
aws-github-role-arn: ${{ secrets.AWS_GITHUB_ROLE_ARN }}
build-and-deploy:
name: Build, tag, and push image to Amazon ECR
runs-on: ubuntu-latest
needs: deploy-cloudformation
permissions:
id-token: write
contents: read
steps:
- name: Checkout Github repo
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_GITHUB_ROLE_ARN }}
aws-region: us-east-1
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to AWS ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPO_NAME }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Create image name
id: get-image
env:
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY_NAME }}
ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPO_NAME }}
IMAGE_TAG: ${{ github.sha }}
run: |
echo ::set-output name=image::${{ format(
'{0}/{1}:{2}',
env.ECR_REGISTRY,
env.ECR_REPOSITORY,
env.IMAGE_TAG
) }}
- name: Deploy to AWS App Runner
id: deploy-app-runner
uses: awslabs/amazon-app-runner-deploy@main
with:
service: fire-starter-service
image: ${{ steps.get-image.outputs.image }}
access-role-arn: ${{ secrets.AWS_APP_RUNNER_ROLE_ARN }}
region: us-east-1
cpu: 1
memory: 2
wait-for-service-stability: true