From 7df8268101bf20941b3548def91384c6ad14ba83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Mi=C4=85cz?= Date: Mon, 30 May 2022 19:22:24 +0200 Subject: [PATCH] Use common workflow for all staging releases (#2051) --- .github/workflows/deploy-staging-v32.yaml | 76 ------------------- .github/workflows/deploy-staging-v33.yaml | 76 ------------------- ...y-staging-v31.yaml => deploy-staging.yaml} | 19 +++-- 3 files changed, 13 insertions(+), 158 deletions(-) delete mode 100644 .github/workflows/deploy-staging-v32.yaml delete mode 100644 .github/workflows/deploy-staging-v33.yaml rename .github/workflows/{deploy-staging-v31.yaml => deploy-staging.yaml} (80%) diff --git a/.github/workflows/deploy-staging-v32.yaml b/.github/workflows/deploy-staging-v32.yaml deleted file mode 100644 index 129870c41..000000000 --- a/.github/workflows/deploy-staging-v32.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: Deploy Dashboard 3.2 to staging -on: - push: - tags: - - 3.2** - 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-staging-v32 - 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_DASHBOARD_STAGING_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_DASHBOARD_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*" - - - name: Prepare Sandbox release pull request - run: | - export GITHUB_TOKEN=$( \ - curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \ - ) - gh api /repos/saleor/saleor-cloud-deployments/dispatches \ - --input - <<< '{ - "event_type": "open-release-pull-request", - "client_payload": { - "project": "DASHBOARD", - "environment": "SANDBOX", - "version": "${{ github.event.inputs.git_ref || github.ref_name }}" - } - }' - - - name: Notify Slack - if: ${{ always() }} - env: - JOB_DEPLOYMENT_KIND: staging - JOB_STATUS: ${{ job.status }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLOUD_DEPLOYMENTS_WEBHOOK_URL }} - JOB_TITLE: "Dashboard deployment to ${{ env.ENVIRONMENT }}" - run: | - python3 ./.github/workflows/notify/notify-slack.py diff --git a/.github/workflows/deploy-staging-v33.yaml b/.github/workflows/deploy-staging-v33.yaml deleted file mode 100644 index 93f4c8bbe..000000000 --- a/.github/workflows/deploy-staging-v33.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: Deploy Dashboard 3.3 to staging -on: - push: - tags: - - 3.3** - 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-staging-v33 - 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_DASHBOARD_STAGING_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_DASHBOARD_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*" - - - name: Prepare Sandbox release pull request - run: | - export GITHUB_TOKEN=$( \ - curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \ - ) - gh api /repos/saleor/saleor-cloud-deployments/dispatches \ - --input - <<< '{ - "event_type": "open-release-pull-request", - "client_payload": { - "project": "DASHBOARD", - "environment": "SANDBOX", - "version": "${{ github.event.inputs.git_ref || github.ref_name }}" - } - }' - - - name: Notify Slack - if: ${{ always() }} - env: - JOB_DEPLOYMENT_KIND: staging - JOB_STATUS: ${{ job.status }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLOUD_DEPLOYMENTS_WEBHOOK_URL }} - JOB_TITLE: "Dashboard deployment to ${{ env.ENVIRONMENT }}" - run: | - python3 ./.github/workflows/notify/notify-slack.py diff --git a/.github/workflows/deploy-staging-v31.yaml b/.github/workflows/deploy-staging.yaml similarity index 80% rename from .github/workflows/deploy-staging-v31.yaml rename to .github/workflows/deploy-staging.yaml index 359e278e9..34f6300f8 100644 --- a/.github/workflows/deploy-staging-v31.yaml +++ b/.github/workflows/deploy-staging.yaml @@ -1,8 +1,9 @@ -name: Deploy Dashboard 3.1 to staging +name: Deploy Dashboard to staging on: push: tags: - - 3.1** + # Matches stable and pre-releases + - "[0-9]+.[0-9]+.[0-9]+*" workflow_dispatch: inputs: git_ref: @@ -21,12 +22,19 @@ jobs: SENTRY_URL_PREFIX: "~/dashboard/static" SENTRY_DSN: ${{ secrets.SENTRY_DSN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - ENVIRONMENT: saleor-staging-v31 + VERSION: ${{ github.event.inputs.git_ref || github.ref_name }} IS_CLOUD_INSTANCE: true steps: - uses: actions/checkout@v2 with: - ref: ${{ github.event.inputs.git_ref || '' }} + ref: ${{ env.VERSION }} + + - name: Set environment + # Convert version into staging deployment name (e.g 3.3.0 -> saleor-staging-v33) + run: | + set -x + environment=$(echo $VERSION | sed -n 's#\([0-9]\+\).\([0-9]\+\).*#saleor-staging-v\1\2#p') + echo "ENVIRONMENT=${environment}" >> $GITHUB_ENV - name: Package timeout-minutes: 15 @@ -55,14 +63,13 @@ jobs: export GITHUB_TOKEN=$( \ curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \ ) - gh api /repos/saleor/saleor-cloud-deployments/dispatches \ --input - <<< '{ "event_type": "open-release-pull-request", "client_payload": { "project": "DASHBOARD", "environment": "SANDBOX", - "version": "${{ github.event.inputs.git_ref || github.ref_name }}" + "version": "${{ env.VERSION }}" } }'