-
Notifications
You must be signed in to change notification settings - Fork 21
164 lines (149 loc) · 5.06 KB
/
deploy_ceramic.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Ceramic CI
on:
push:
branches: [main]
paths:
- '.cdk/**'
- 'docker-compose.yml'
- '.ebextensions/ceramic/**'
- '.ebstalk.apps.env/ceramic.env'
- '.github/actions/**'
- '.github/workflows/deploy_ceramic.yml'
- 'package.json'
- 'package-lock.json'
- 'apps/ceramic/**'
pull_request:
types: [labeled, opened, synchronize]
branches: ['**']
paths:
- '.cdk/**'
- 'docker-compose.yml'
- '.ebextensions/ceramic/**'
- '.ebstalk.apps.env/ceramic.env'
- '.github/actions/**'
- '.github/workflows/deploy_ceramic.yml'
- 'package.json'
- 'package-lock.json'
- 'apps/ceramic/**'
workflow_dispatch:
inputs:
core_pkg_version:
description: 'Core pkg version to update to'
required: true
concurrency:
group: ci-ceramic-${{ github.event_name }}-${{ github.ref }}
jobs:
build:
name: Build Ceramic
runs-on: ubuntu-latest
outputs:
head_commit_message: ${{ steps.setup_variables.outputs.commit_message }}
deploy_staging: ${{ steps.setup_variables.outputs.deploy_staging }}
skip_tests: ${{ steps.setup_variables.outputs.skip_tests }}
steps:
- name: Print Triggering event context payload
env:
workflow_event_context: ${{ toJSON(github.event) }}
run: |
echo "$workflow_event_context"
echo "Workflow and code ref: ${{github.ref}}"
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup variables
id: setup_variables
# source https://github.com/orgs/community/discussions/28474
run: |
echo "commit_message=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"
echo "deploy_staging=${{(github.event.action == 'labeled' && github.event.label.name == ':rocket: deploy-ceramic') || (github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, ':rocket: deploy-ceramic'))}}" >> $GITHUB_OUTPUT
echo "skip_tests=${{ contains(env.commit_message, 'skip-tests') }}" >> $GITHUB_OUTPUT
- name: Install dependencies
uses: ./.github/actions/install
with:
app_name: ceramic
core_pkg_version: ${{ inputs.core_pkg_version }}
commit_core_pkg_upgrade: true
- name: Build app
uses: ./.github/actions/build_app
with:
app_name: ceramic
upload-docker:
name: Upload Docker image
runs-on: ubuntu-latest
# run whether previous jobs were successful or skipped
if: |
github.ref == 'refs/heads/main' || needs.build.outputs.deploy_staging == 'true'
needs: build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
uses: ./.github/actions/install
with:
app_name: ceramic
- name: Restore app from cache
uses: ./.github/actions/build_app
with:
app_name: ceramic
- name: Update Dockerfile
run: |
rm Dockerfile && mv apps/ceramic/Dockerfile Dockerfile
- name: Build and Push Docker image
id: docker_build_push
uses: ./.github/actions/build_docker_image
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
with:
ecr_registry: ceramic
deploy-production:
name: Deploy to production
# run whether previous jobs were successful or skipped
if: github.ref == 'refs/heads/main' && !(failure() || cancelled())
needs: [upload-docker]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/deploy_production
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
with:
app_name: ceramic
stack: prd-ceramic
deploy-staging:
name: Deploy to staging
if: needs.build.outputs.deploy_staging == 'true'
runs-on: ubuntu-latest
# prevent staging deploys + cleanup running in parallel
concurrency: staging-${{ github.ref }}
needs: [build, upload-docker]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/deploy_staging
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
app_name: ceramic
discord-alert:
name: Notify Discord of failure
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && failure()
# pass in all steps so we can check if any failed
needs: [upload-docker, deploy-production]
steps:
- uses: actions/checkout@v4
- name: Notify Discord
uses: ./.github/actions/notify_error
env:
DISCORD_WARNINGS_WEBHOOK: ${{ secrets.DISCORD_WARNINGS_WEBHOOK }}
with:
app_name: ceramic