-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (114 loc) · 3.88 KB
/
deploy.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
name: 'Deploy'
on:
push:
branches:
- master
jobs:
infrastructure:
name: 'Infrastructure'
runs-on: ubuntu-latest
# Checkout the repository to the GitHub Actions runner
steps:
- name: Checkout
uses: actions/checkout@v4
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.1.7"
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
working-directory: 'infrastructure'
run: terraform init
# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
working-directory: 'infrastructure'
run: terraform fmt -check
# Build cluster first
- name: Terraform Apply
working-directory: 'infrastructure'
run: terraform apply -auto-approve
services:
name: 'Serverless'
needs: infrastructure
runs-on: ubuntu-latest
# Required for Github-AWS OIDC to work
permissions:
id-token: write
contents: read
# Checkout the repository to the GitHub Actions runner
steps:
- name: Checkout
uses: actions/checkout@v4
# Configure AWS Credentials
# Basically run 'aws configure' as you would from local CLI
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::633025216388:role/GithubActions-Fairbanksio-F5oclock
role-duration-seconds: 1200 # Optional duration, 20 minutes in this case
# Install Nodejs
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
# Deploy Posts Service
- run: npm ci
name: "Posts Service - Install dependencies"
working-directory: 'services/posts'
- name: "Posts Service - Deploy"
uses: serverless/[email protected]
with:
args: -c "cd ./services/posts && serverless deploy"
entrypoint: /bin/sh
# Deploy Scraper Service
- run: npm ci
name: "Scraper Service - Install dependencies"
working-directory: 'services/scraper'
- name: "Scraper Service - Deploy"
uses: serverless/[email protected]
with:
args: -c "cd ./services/scraper && serverless deploy"
entrypoint: /bin/sh
# Deploy Subreddits Service
- run: npm ci
name: "Subreddits Service - Install dependencies"
working-directory: 'services/subreddits'
- name: "Subreddits Service - Deploy"
uses: serverless/[email protected]
with:
args: -c "cd ./services/subreddits && serverless deploy"
entrypoint: /bin/sh
webapp:
name: 'Web App'
needs: services
runs-on: ubuntu-latest
# Required for Github-AWS OIDC to work
permissions:
id-token: write
contents: read
# Checkout the repository to the GitHub Actions runner
steps:
- name: Checkout
uses: actions/checkout@v4
# Configure AWS Credentials
# Basically run 'aws configure' as you would from local CLI
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::633025216388:role/GithubActions-Fairbanksio-F5oclock
role-duration-seconds: 1200 # Optional duration, 20 minutes in this case
# Install Nodejs
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
# Deploy Posts Service
- run: npm ci
name: "Install dependencies"
working-directory: 'webui'
- run: npm run deploy
name: "Deploy"
working-directory: 'webui'