-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (109 loc) · 3.73 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
name: Deploy
on:
push:
branches:
- development
- master
jobs:
deploy-staging:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/development'
steps:
- name: Send Slack Message
uses: voxmedia/github-action-slack-notify-build@v1
id: slack
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
with:
channel_id: ${{ vars.CHANNEL_ID }}
status: STARTING
color: warning
- name: Add Docker Cache Layer
uses: satackey/[email protected]
continue-on-error: true
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.GIT_PAT }}
ref: development
# ... contents as before
- name: Set my SSH key and ssh-agent
uses: webfactory/[email protected]
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 18
- name: Install dependencies
run: yarn install
working-directory: src
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Run test
run: docker-compose run addressbook npm test
id: test
working-directory: src
continue-on-error: true
- name: Notify Failure
if: steps.test.outcome == 'failure'
uses: voxmedia/github-action-slack-notify-build@v1
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
with:
channel_id: ${{ vars.CHANNEL_ID }}
message_id: ${{ steps.slack.outputs.message_id }}
status: FAILURE
color: danger
- name: Run playbook
uses: dawidd6/action-ansible-playbook@v2
id: deploy
with:
# Required, playbook filepath
playbook: deploy.yml
# Optional, directory where playbooks live
directory: ./ansible
inventory: |
[staging]
165.227.139.136
[web]
165.227.139.136
# Optional, ansible configuration file content (ansible.cfg)
configuration: |
[defaults]
host_key_checking = True
log_path = /var/log/ansible.log
force_color = True
inventory = hosts
[ssh_connection]
ssh_args = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o [email protected],[email protected],ssh-ed25519,ssh-rsa
retries = 1
# Optional, SSH private key
key: ${{secrets.SSH_PRIVATE_KEY}}
# Optional, additional flags to pass to ansible-playbook
options: |
--e env=staging
- name: Notify Failure
if: steps.deploy.outcome == 'failure'
uses: voxmedia/github-action-slack-notify-build@v1
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
with:
channel_id: ${{ vars.CHANNEL_ID }}
message_id: ${{ steps.slack.outputs.message_id }}
status: FAILURE
color: danger
- name: Notify Success
if: steps.deploy.outcome == 'success'
uses: voxmedia/github-action-slack-notify-build@v1
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
with:
channel_id: ${{ vars.CHANNEL_ID }}
message_id: ${{ steps.slack.outputs.message_id }}
status: SUCCESS
color: good