-
Notifications
You must be signed in to change notification settings - Fork 111
45 lines (35 loc) · 1.53 KB
/
deploy-to-production.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
name: deploy-to-production
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
deploy:
runs-on: [self-hosted, infra]
name: Deploy to production
environment:
name: production
url: https://docs.centreon.com
steps:
- name: Setup awscli
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
sudo unzip -q awscliv2.zip
sudo ./aws/install
shell: bash
- name: Deploy from staging to https://docs.centreon.com
run: |
# Prepare ssh-key
eval `ssh-agent`
ssh-add - <<< "${{ secrets.INT_SSH_KEY }}"
ssh -o StrictHostKeyChecking=no [email protected] rsync -arzvh --delete /var/www/html [email protected]:/var/www/ \
|| ssh -o StrictHostKeyChecking=no admin@${{ secrets.DOC_DEV_IP_ADDRESS }} rsync -arzvh --delete /var/www/html admin@${{ secrets.DOC_PROD_IP_ADDRESS }}:/var/www/
export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" \
$(aws sts assume-role \
--role-arn ${{ secrets.CLOUDFRONT_ROLE_DOC_PRODUCTION }} \
--role-session-name InvalidDocCache \
--query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \
--output text))
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_ID_DOC_PRODUCTION }} --paths "/*"
shell: bash