-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmulti-instance.yml
More file actions
49 lines (42 loc) · 1.47 KB
/
multi-instance.yml
File metadata and controls
49 lines (42 loc) · 1.47 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
name: Deploy to multiple instances
# Dispatch a command to several instances in parallel and stream output per instance.
# SSM runs the command on all instances simultaneously — not sequentially.
on:
push:
branches: [main]
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: false
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS credentials (OIDC)
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
with:
role-to-assume: arn:aws:iam::123456789012:role/my-deploy-role
aws-region: us-east-1
- name: Deploy to all app servers
id: deploy
uses: zAbuQasem/ssm-run-command@10be2ff3863ef31e5459092c0be8538fbc0907f8 # v2.0.0
with:
aws-region: us-east-1
instance-ids: |
${{ secrets.INSTANCE_ID_1 }}
${{ secrets.INSTANCE_ID_2 }}
${{ secrets.INSTANCE_ID_3 }}
working-directory: /home/ubuntu/app
wait-for-output: true
wait-timeout: 180
comment: Deploy ${{ github.sha }}
command: |
git pull origin main
npm install --production
pm2 restart all
# Output is prefixed per instance when targeting multiple: [i-xxxxx]\n<stdout>
- name: Print per-instance output
run: echo "${{ steps.deploy.outputs.output }}"