Merge remote-tracking branch 'origin/main' into github-action-deploy #13
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy cluster | |
on: | |
push: | |
branches: [github-action-deploy] | |
workflow_dispatch: | |
jobs: | |
deploy-production: | |
name: Deploy on production | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
strategy: | |
matrix: | |
include: | |
- environment: production-01 | |
host: SSH_HOST_PRODUCTION_01 | |
- environment: production-02 | |
host: SSH_HOST_PRODUCTION_02 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up SSH | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$SSH_PRIVATE_KEY" > ./deploy.key | |
sudo chmod 600 ./deploy.key | |
ssh-keyscan -H $SSH_HOST >> ~/.ssh/known_hosts | |
shell: bash | |
env: | |
SSH_PRIVATE_KEY: ${{secrets.SSH_MACHINE_USER_PRIVATE_KEY}} | |
SSH_HOST: ${{ secrets[matrix.host] }} | |
- name: Deploy to production | |
run: ssh -i ./deploy.key www-data@$SSH_HOST 'python3 /opt/scripts/app-deploy-release/deploy.py /opt/git/releases/annuaire-entreprises-search-api https://github.com/etalab/annuaire-entreprises-search-api.git api --version github-action-deploy --versions_to_keep=5 | tee --append /var/log/deploy_annuaire-entreprises-search-api' | |
env: | |
SSH_HOST: ${{ secrets[matrix.host] }} | |
- name: Notify staging failure only | |
if: failure() | |
uses: ./.github/actions/notify | |
with: | |
message: '🚨 ${{ github.event.repository.name }} [${{ matrix.environment }}] : deploy to production cluster failed' | |
hook: ${{ secrets.TCHAP_HOOK }} | |
id: ${{ secrets.TCHAP_ROOM_ID }} | |
notify-deploy-success: | |
name: Notify successful deployment | |
runs-on: ubuntu-latest | |
needs: [deploy-production] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Notify deploy success | |
uses: ./.github/actions/notify | |
with: | |
message: '✅ ${{ github.event.repository.name }} : successfully deploy production cluster' | |
hook: ${{ secrets.TCHAP_HOOK }} | |
id: ${{ secrets.TCHAP_ROOM_ID }} |