diff --git a/.github/workflows/deploy-prod.yaml b/.github/workflows/deploy-cloud.yaml similarity index 74% rename from .github/workflows/deploy-prod.yaml rename to .github/workflows/deploy-cloud.yaml index b67782837..db81fa462 100644 --- a/.github/workflows/deploy-prod.yaml +++ b/.github/workflows/deploy-cloud.yaml @@ -1,16 +1,7 @@ -name: Deploy to production +name: Deploy to cloud 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 + repository_dispatch: + types: cloud-deployment jobs: build: @@ -22,19 +13,20 @@ jobs: SENTRY_ORG: saleor SENTRY_PROJECT: dashboard SENTRY_URL_PREFIX: "~/dashboard/static" - ENVIRONMENT: ${{ github.event.inputs.service_name }} + ENVIRONMENT: ${{ github.event.client_payload.deployment_name }} + REGION: ${{ github.event.client_payload.region }} 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 }} + ref: ${{ github.event.client_payload.ref }} - name: Package timeout-minutes: 15 run: | npm ci - - name: build + - name: Build run: | npm run build - name: Configure AWS Credentials @@ -45,7 +37,6 @@ jobs: 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 }} diff --git a/.github/workflows/deploy-staging.yaml b/.github/workflows/deploy-latest-staging.yaml similarity index 67% rename from .github/workflows/deploy-staging.yaml rename to .github/workflows/deploy-latest-staging.yaml index 3072a1583..6b55c4829 100644 --- a/.github/workflows/deploy-staging.yaml +++ b/.github/workflows/deploy-latest-staging.yaml @@ -1,17 +1,14 @@ -name: Deploy to staging +name: Deploy Dashboard 3.1 to latest staging on: push: - branches: - - master - - ci/staging/** + tags: + - 3.1** workflow_dispatch: inputs: git_ref: description: Git ref (tag, branch or commit hash) with helm chart to deploy required: true - service_name: - description: Name of the service - required: true + jobs: build: runs-on: ubuntu-20.04 @@ -24,38 +21,29 @@ jobs: SENTRY_URL_PREFIX: "~/dashboard/static" SENTRY_DSN: ${{ secrets.SENTRY_DSN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + ENVIRONMENT: saleor-latest-staging IS_CLOUD_INSTANCE: true steps: - - name: Set env variables - run: | - set -x - - GIT_REF_INPUT=${{ github.event.inputs.git_ref }} - GIT_REF="${GIT_REF_INPUT:=master}" - - SERVICE_NAME_INPUT=${{ github.event.inputs.service_name }} - SERVICE_NAME="${SERVICE_NAME_INPUT:=saleor-master-staging}" - - echo "GIT_REF=$GIT_REF" >> $GITHUB_ENV - # ENVIRONMENT variable is provided to sentry at build time - echo "ENVIRONMENT=$SERVICE_NAME" >> $GITHUB_ENV - - uses: actions/checkout@v2 with: - ref: ${{ env.GIT_REF }} + 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_STAGING_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_STAGING_SECRET_ACCESS_KEY }} aws-region: us-east-1 + - name: Deploy run: | aws s3 sync build/dashboard s3://${{ secrets.AWS_STAGING_DEPLOYMENT_BUCKET }}/${ENVIRONMENT}/static/ diff --git a/.github/workflows/deploy-master-staging.yaml b/.github/workflows/deploy-master-staging.yaml new file mode 100644 index 000000000..dd4965a68 --- /dev/null +++ b/.github/workflows/deploy-master-staging.yaml @@ -0,0 +1,45 @@ +name: Deploy Dashboard to master staging +on: + push: + branches: + - master + - ci/staging/** + workflow_dispatch: +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" + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + ENVIRONMENT: saleor-master-staging + IS_CLOUD_INSTANCE: true + steps: + - uses: actions/checkout@v2 + + - 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_STAGING_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_STAGING_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Deploy + run: | + aws s3 sync build/dashboard s3://${{ secrets.AWS_STAGING_DEPLOYMENT_BUCKET }}/${ENVIRONMENT}/static/ + aws s3 cp build/dashboard/index.html s3://${{ secrets.AWS_STAGING_DEPLOYMENT_BUCKET }}/${ENVIRONMENT}/ + aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_STAGING_CF_DIST_ID }} --paths "/dashboard*" diff --git a/.github/workflows/deploy-stable-staging.yaml b/.github/workflows/deploy-stable-staging.yaml new file mode 100644 index 000000000..971c0834d --- /dev/null +++ b/.github/workflows/deploy-stable-staging.yaml @@ -0,0 +1,51 @@ +name: Deploy Dashboard 3.0 to stable staging +on: + push: + tags: + - 3.0** + workflow_dispatch: + inputs: + git_ref: + description: Git ref (tag, branch or commit hash) with helm chart 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" + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + ENVIRONMENT: saleor-stable-staging + 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_STAGING_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_STAGING_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Deploy + run: | + aws s3 sync build/dashboard s3://${{ secrets.AWS_STAGING_DEPLOYMENT_BUCKET }}/${ENVIRONMENT}/static/ + aws s3 cp build/dashboard/index.html s3://${{ secrets.AWS_STAGING_DEPLOYMENT_BUCKET }}/${ENVIRONMENT}/ + aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_STAGING_CF_DIST_ID }} --paths "/dashboard*"