-
Notifications
You must be signed in to change notification settings - Fork 18
100 lines (99 loc) · 3.89 KB
/
ci.yml
File metadata and controls
100 lines (99 loc) · 3.89 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: ci
on:
push:
branches:
- master
- test
jobs:
ci:
name: ci
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
outputs:
image-tag: "${{ steps.login-ecr.outputs.registry }}/rko-router:${{ github.sha }}-amd64"
steps:
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1.288.0
with:
ruby-version: '4.0'
bundler-cache: true
- uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0
with:
aws-region: "us-west-2"
role-skip-session-tagging: true
role-to-assume: "arn:aws:iam::005216166247:role/GhaRkoRouterDeploy"
mask-aws-account-id: 'false' # only string works
- id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
- name: 'Build Docker image'
uses: 'docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8' # v6.19.2
with:
context: '.'
load: true
tags: "rko-router-test:latest,${{ steps.login-ecr.outputs.registry }}/rko-router:${{ github.sha }},${{ steps.login-ecr.outputs.registry }}/rko-router:latest"
cache-from: type=gha
cache-to: type=gha,mode=max
- name: 'Start container for test'
run: |
set -x
docker kill rko-router-dut || :
docker container wait rko-router-dut || :
while docker inspect rko-router-dut >/dev/null; do sleep 1; done
docker run --rm --name rko-router-dut --publish 127.0.0.1::8080 --detach rko-router-test:latest
export TARGET_HOST="http://$(docker port rko-router-dut 8080)"
for i in {1..10}; do
if curl -Ssf "${TARGET_HOST}/healthz"; then break; fi
sleep 1
done
curl -f -D- "${TARGET_HOST}/healthz"
- name: 'Run test suite'
run: |
set -x
export TARGET_HOST="http://$(docker port rko-router-dut 8080)"
bundle exec rspec -fd || ( docker logs rko-router-dut; false )
- name: 'Push Docker tag'
uses: 'docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8' # v6.19.2
with:
context: '.'
push: true
tags: "${{ steps.login-ecr.outputs.registry }}/rko-router:${{ github.sha }},${{ steps.login-ecr.outputs.registry }}/rko-router:latest"
cache-from: type=gha
cache-to: type=gha,mode=max
- name: 'Push Docker tag (non-manifest)'
uses: 'docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8' # v6.19.2
with:
context: '.'
push: true
tags: "${{ steps.login-ecr.outputs.registry }}/rko-router:${{ github.sha }}-amd64"
cache-from: type=gha
cache-to: type=gha,mode=max
# Lambda does not support manifest list
sbom: false
provenance: false
deploy-lambda:
name: deploy-lambda
if: "github.ref == 'refs/heads/master'"
environment:
name: lambda-prod
url: https://rko-router.rubykaigi.org
concurrency:
group: lambda-prod
permissions:
contents: read
id-token: write
runs-on: ubuntu-slim
needs:
- ci
steps:
- uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0
with:
aws-region: "us-west-2"
role-skip-session-tagging: true
role-to-assume: "arn:aws:iam::005216166247:role/GhaRkoRouterDeploy"
mask-aws-account-id: 'false' # only string works
- run: 'aws lambda update-function-code --function-name rko-router --image-uri "$IMAGE_URI"'
env:
IMAGE_URI: "${{needs.ci.outputs.image-tag}}"