-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (75 loc) · 2.5 KB
/
cd.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
name: "Continuous Deployment"
on:
workflow_dispatch:
push:
branches:
- dev
- main
concurrency: ci-${{ github.ref }}
env:
ECLIPSE_SSH_HOST: eclipse.mes-aides.incubateur.net
ECLIPSE_SSH_USER: debian
EQUINOXE_SSH_HOST: equinoxe.mes-aides.1jeune1solution.beta.gouv.fr
EQUINOXE_SSH_USER: debian
jobs:
install_python_requirements:
name: Install Python requirements
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
- name: Cache Python dependencies
uses: actions/cache@v4
id: python-dependencies
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-dependencies-${{ hashFiles('**/requirements.txt') }}
- name: Install dependencies
run: pip install -r requirements.txt
lint_ansible_files:
name: Lint ansible files
runs-on: ubuntu-20.04
needs: [install_python_requirements]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
- name: Cache Python dependencies
uses: actions/cache@v4
id: python-dependencies
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-dependencies-${{ hashFiles('**/requirements.txt') }}
- name: Check installed package
run: pip freeze
- name: Run ansible lint
run: ansible-lint --offline
deploy_production:
name: Deploy production (Equinoxe)
runs-on: ubuntu-20.04
needs: [install_python_requirements, lint_ansible_files]
if: github.ref == 'refs/heads/main'
steps:
- name: Equinoxe Deployment
shell: bash
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.EQUINOXE_PRIVATE_KEY }}" > ~/.ssh/equinoxe
chmod 600 ~/.ssh/equinoxe
ssh -o StrictHostKeyChecking=no ${{ env.EQUINOXE_SSH_USER }}@${{ env.EQUINOXE_SSH_HOST }} -i ~/.ssh/equinoxe
deploy_preproduction:
name: Deploy preproduction (Eclipse)
runs-on: ubuntu-20.04
needs: [install_python_requirements, lint_ansible_files]
if: github.ref == 'refs/heads/dev'
steps:
- name: Eclipse Deployment
shell: bash
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.ECLIPSE_PRIVATE_KEY }}" > ~/.ssh/eclipse
chmod 600 ~/.ssh/eclipse
ssh -o StrictHostKeyChecking=no ${{ env.ECLIPSE_SSH_USER }}@${{ env.ECLIPSE_SSH_HOST }} -i ~/.ssh/eclipse