saleor-dashboard/.github/workflows/deploy-prod.yaml
Jakub Majorek dbaed5478a
App adjustments (#1385)
* Use shop domain as backendHost, guard domain changes on cloud instances

* Update messages and snapshots

* Remove unused prop
2021-09-13 16:14:04 +02:00

62 lines
2 KiB
YAML

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 }}
IS_CLOUD_INSTANCE: true
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.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*"