deploy-to-production #335
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-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 |