Skip to content

Commit

Permalink
Maj workflows CI/CD (#186)
Browse files Browse the repository at this point in the history
* fix: cd on dev branch

* feat: déplace la CI dans un workflow dédié
  • Loading branch information
Shamzic authored Feb 7, 2024
1 parent 41b3af4 commit b993283
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 30 deletions.
59 changes: 29 additions & 30 deletions .github/workflows/pipeline.yaml → .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
name: "Continuous Integration"
name: "Continuous Deployment"
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
push:
branches:
- dev
- main
concurrency: ci-${{ github.ref }}

env:
ECLIPSE_SSH_HOST: 51.91.16.19
ECLIPSE_SSH_HOST: eclipse.mes-aides.incubateur.net
ECLIPSE_SSH_USER: debian
EQUINOXE_SSH_HOST: 5.135.137.147
EQUINOXE_SSH_HOST: equinoxe.mes-aides.1jeune1solution.beta.gouv.fr
EQUINOXE_SSH_USER: debian


jobs:
install:
install_python_requirements:
name: Install Python requirements
runs-on: ubuntu-20.04
steps:
Expand All @@ -29,10 +30,10 @@ jobs:
key: ${{ runner.os }}-python-dependencies-${{ hashFiles('**/requirements.txt') }}
- name: Install dependencies
run: pip install -r requirements.txt
lint:
lint_ansible_files:
name: Lint ansible files
runs-on: ubuntu-20.04
needs: [install]
needs: [install_python_requirements]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -48,33 +49,31 @@ jobs:
run: pip freeze
- name: Run ansible lint
run: ansible-lint --offline
deployment:
name: Continuous deployment

deploy_production:
name: Deploy production (Equinoxe)
runs-on: ubuntu-20.04
needs: [install, lint]
needs: [install_python_requirements, lint_ansible_files]
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
- name: Cache Python dependencies
uses: actions/cache@v3
id: python-dependencies
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-dependencies-${{ hashFiles('**/requirements.txt') }}
- 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
- 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
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Continuous Integration"
on:
workflow_dispatch:
pull_request:

jobs:
install_python_requirements:
name: Install Python requirements
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
- name: Cache Python dependencies
uses: actions/cache@v3
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@v3
- name: Setup Python
uses: actions/setup-python@v4
- name: Cache Python dependencies
uses: actions/cache@v3
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

0 comments on commit b993283

Please sign in to comment.