-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (74 loc) · 2.67 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
name: 'Deploy to AWS'
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: read
jobs:
deploy:
name: 'Deploy to EC2'
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: '1.17.3'
otp-version: '27.1'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies
run: |
mix local.hex --force
mix local.rebar --force
mix deps.get
- name: Setup and Build Assets
run: |
npm install --prefix assets
- name: Create Production Release
env:
MIX_ENV: prod
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
run: |
mix compile
mix phx.digest
mix release --overwrite
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Create or Update CodeDeploy Application
run: |
aws deploy create-application \
--application-name digistab_store || true
- name: Create or Update Deployment Group
run: |
aws deploy create-deployment-group \
--application-name digistab_store \
--deployment-group-name digistab_store-production \
--service-role-arn ${{ secrets.AWS_CODEDEPLOY_SERVICE_ROLE }} \
--deployment-style deploymentType=IN_PLACE,deploymentOption=WITHOUT_TRAFFIC_CONTROL \
--ec2-tag-filters Key=Environment,Type=KEY_AND_VALUE,Value=Production || true
- name: Create Deployment Package
run: |
mkdir -p deployment-package
cp -r _build/prod/rel/digistab_store deployment-package/
cp appspec.yml deployment-package/
cp -r scripts deployment-package/
cd deployment-package
zip -r ../deployment-package.zip .
- name: Create CodeDeploy Deployment
run: |
aws deploy create-deployment \
--application-name digistab_store \
--deployment-group-name digistab_store-production \
--github-location repository=${{ github.repository }},commitId=${{ github.sha }}