Add workflow for production deployment
This commit is contained in:
parent
d5a36e47fc
commit
f97d13ceef
1 changed files with 61 additions and 0 deletions
61
.github/workflows/deploy-prod.yaml
vendored
Normal file
61
.github/workflows/deploy-prod.yaml
vendored
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
name: Deploy to production
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
service_name:
|
||||||
|
description: Name of the service
|
||||||
|
required: true
|
||||||
|
region:
|
||||||
|
description: Region to which deploy (eu or us)
|
||||||
|
required: true
|
||||||
|
git_ref:
|
||||||
|
description: Git ref (tag, branch or full commit hash) to deploy
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
env:
|
||||||
|
API_URI: /graphql/
|
||||||
|
APP_MOUNT_URI: /dashboard/
|
||||||
|
STATIC_URL: /dashboard/static/
|
||||||
|
SENTRY_ORG: saleor
|
||||||
|
SENTRY_PROJECT: dashboard
|
||||||
|
SENTRY_URL_PREFIX: "~/dashboard/static"
|
||||||
|
ENVIRONMENT: ${{ github.event.inputs.service_name }}
|
||||||
|
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
|
||||||
|
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.inputs.chart_git_ref }}
|
||||||
|
- name: Package
|
||||||
|
timeout-minutes: 15
|
||||||
|
run: |
|
||||||
|
npm ci
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
npm run build
|
||||||
|
- name: Configure AWS Credentials
|
||||||
|
uses: aws-actions/configure-aws-credentials@v1
|
||||||
|
with:
|
||||||
|
aws-access-key-id: ${{ secrets.AWS_PROD_ACCESS_KEY_ID }}
|
||||||
|
aws-secret-access-key: ${{ secrets.AWS_PROD_SECRET_ACCESS_KEY }}
|
||||||
|
aws-region: us-east-1
|
||||||
|
- name: Deploy
|
||||||
|
run: |
|
||||||
|
REGION=${{ github.event.inputs.region }}
|
||||||
|
if [[ "$REGION" == "us" ]]; then
|
||||||
|
BUCKET=${{ secrets.AWS_PROD_US_DEPLOYMENT_BUCKET }}
|
||||||
|
CF_ID=${{ secrets.AWS_PROD_US_CF_DIST_ID }}
|
||||||
|
elif [[ "$REGION" == "eu" ]]; then
|
||||||
|
BUCKET=${{ secrets.AWS_PROD_EU_DEPLOYMENT_BUCKET }}
|
||||||
|
CF_ID=${{ secrets.AWS_PROD_EU_CF_DIST_ID }}
|
||||||
|
else
|
||||||
|
echo "Unknown region provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
aws s3 sync build/dashboard s3://${BUCKET}/${ENVIRONMENT}/static/
|
||||||
|
aws s3 cp build/dashboard/index.html s3://${BUCKET}/${ENVIRONMENT}/
|
||||||
|
aws cloudfront create-invalidation --distribution-id ${CF_ID} --paths "/dashboard*"
|
Loading…
Reference in a new issue