-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (61 loc) · 2.45 KB
/
aws.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
71
72
on:
pull_request:
types: [opened, synchronize, reopened]
name: Deploy branch
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: 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: eu-west-1
- name: Extract pull request number
shell: bash
run: echo "##[set-output name=number;]$(jq --raw-output .pull_request.number $GITHUB_EVENT_PATH)"
id: pull_request
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: latest
ECR_REPOSITORY: hello-world-app
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: cdk deploy
uses: youyo/aws-cdk-github-actions@v1
with:
cdk_subcommand: "deploy HisingenHackathonServiceStack-${{ steps.pull_request.outputs.number }} --require-approval never"
actions_comment: false
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'eu-west-1'
BRANCH_SUFFIX: ${{ steps.pull_request.outputs.number }}
- name: Extract service link
shell: bash
run: echo "##[set-output name=link;]$(echo $(aws cloudformation describe-stacks --stack-name HisingenHackathonServiceStack-${{ steps.pull_request.outputs.number }} --query 'Stacks[0].Outputs[*].OutputValue' | grep http))"
env:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
id: service_url
- name: Comment a pull_request
uses: mb2dev/github-action-comment-pull-request@1.0.0
with:
message: ${{ steps.service_url.outputs.link }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
reactions: "confused | rocket"