-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (47 loc) · 1.45 KB
/
deploy.yml
File metadata and controls
55 lines (47 loc) · 1.45 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
50
51
52
53
54
55
name: Deploy
on:
workflow_dispatch:
inputs:
environment:
description: "Environment to deploy to"
required: true
default: "production"
type: choice
options:
- production
- staging
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Ansible
run: |
python -m pip install --upgrade pip
pip install ansible
- name: Set up SSH key
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
run: |
mkdir -p ~/.ssh
echo "$DEPLOY_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -t rsa 65.108.97.170 >> ~/.ssh/known_hosts
ssh-keyscan -t rsa 65.108.197.86 >> ~/.ssh/known_hosts
- name: Deploy to Production
if: github.event_name == 'push' || github.event.inputs.environment == 'production'
run: |
ansible-playbook ansible/deploy.yml \
-i ansible/inventory.ini \
--private-key ~/.ssh/deploy_key
- name: Deploy to Staging
if: github.event.inputs.environment == 'staging'
run: |
ansible-playbook ansible/deploy.yml \
-i ansible/inventory.ini \
--private-key ~/.ssh/deploy_key \
--limit kindle-automator-staging