forked from ruby-no-kai/sponsor-app
-
Notifications
You must be signed in to change notification settings - Fork 4
82 lines (80 loc) · 2.82 KB
/
ci.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
73
74
75
76
77
78
79
80
81
82
name: ci
on:
push:
branches:
- master
- test
jobs:
build:
name: build
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
outputs:
image-tag: "${{ steps.login-ecr.outputs.registry }}/sponsor-app:${{ github.sha }}"
steps:
- uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v4
#- uses: ruby/setup-ruby@v1
# with:
# ruby-version: '3.1'
# bundler-cache: true
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: "us-west-2"
role-skip-session-tagging: true
role-to-assume: "arn:aws:iam::005216166247:role/GhaDockerPush"
mask-aws-account-id: false
- id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- run: "echo '${{ github.sha }}' > REVISION"
- name: 'Build Docker image'
uses: 'docker/build-push-action@v3'
with:
context: '.'
load: true
tags: "sponsor-app-test:latest,${{ steps.login-ecr.outputs.registry }}/sponsor-app:${{ github.sha }},${{ steps.login-ecr.outputs.registry }}/sponsor-app:latest"
cache-from: type=gha
cache-to: type=gha,mode=max
- name: 'Push Docker image'
uses: 'docker/build-push-action@v3'
with:
context: '.'
push: true
tags: "${{ steps.login-ecr.outputs.registry }}/sponsor-app:${{ github.sha }},${{ steps.login-ecr.outputs.registry }}/sponsor-app:latest"
deploy-prod:
if: "${{ success() && github.event_name == 'push' }}"
name: deploy-prod
needs: ["build"]
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
concurrency:
group: production
cancel-in-progress: true
environment:
name: production
url: https://sponsorships.rubykaigi.org
env:
BUNDLE_GEMFILE: "${{ github.workspace }}/deploy/Gemfile"
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: "us-west-2"
role-skip-session-tagging: true
role-to-assume: "arn:aws:iam::005216166247:role/GhaSponsorDeploy"
mask-aws-account-id: false
- name: 'Run pre-deploy task'
run: "bundle exec hako oneshot --tag '${{ github.sha }}' ./deploy/hako/sponsor-app-batch.jsonnet bundle exec rake db:migrate"
- name: "Deploy sponsor-app-worker (ECS)"
run: "bundle exec hako deploy --tag '${{ github.sha }}' ./deploy/hako/sponsor-app-worker.jsonnet"
- name: "Deploy sponsor-app (App Runner)"
working-directory: '${{ github.workspace }}/tf/'
run: "terraform init && terraform apply -target=aws_apprunner_service.prd -auto-approve"