Skip to content

Upgrade actions/upload-artifact to v4 (#5325) #1739

Upgrade actions/upload-artifact to v4 (#5325)

Upgrade actions/upload-artifact to v4 (#5325) #1739

name: Deploy Dashboard to main staging
on:
push:
branches:
- main
- ci/staging/**
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-20.04
env:
## backward compatibility for older versions
API_URI: /graphql/
## backward compatibility for older versions
APPS_MARKETPLACE_API_URI: "https://apps.staging.saleor.io/api/v2/saleor-apps"
API_URL: /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 }}
APPS_MARKETPLACE_API_URL: "https://apps.staging.saleor.io/api/v2/saleor-apps"
IS_CLOUD_INSTANCE: true
POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }}
POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }}
ONBOARDING_USER_JOINED_DATE_THRESHOLD: ${{ vars.STAGING_ONBOARDING_USER_JOINED_DATE_THRESHOLD }}
steps:
- uses: actions/checkout@v2
- name: Set custom version
run: |
HASH=$(git rev-parse --short HEAD)
CURRENT_VERSION=$(jq -r .version package.json)
RELEASE="${CURRENT_VERSION}-${HASH}"
echo "CUSTOM_VERSION=${RELEASE}" >> $GITHUB_ENV
echo "SENTRY_RELEASE=${RELEASE}" >> $GITHUB_ENV
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- 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_CLOUD_STAGING_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_CLOUD_STAGING_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Deploy master staging
run: |
aws s3 sync build/dashboard "s3://${DEPLOYMENT_BUCKET}/saleor-master-staging/static/"
aws s3 cp build/dashboard/index.html "s3://${DEPLOYMENT_BUCKET}/saleor-master-staging/"
env:
DEPLOYMENT_BUCKET: ${{ secrets.AWS_CLOUD_STAGING_DEPLOYMENT_BUCKET }}
- name: Deploy fake production
run: |
aws s3 sync build/dashboard "s3://${DEPLOYMENT_BUCKET}/saleor-fake-production/static/"
aws s3 cp build/dashboard/index.html "s3://${DEPLOYMENT_BUCKET}/saleor-fake-production/"
env:
DEPLOYMENT_BUCKET: ${{ secrets.AWS_CLOUD_STAGING_DEPLOYMENT_BUCKET }}
- name: Invalidate cache
run: |
IFS=',' read -ra DISTRIBUTIONS_ARRAY <<< "$CDN_DISTRIBUTIONS"
for DISTRIBUTION in "${DISTRIBUTIONS_ARRAY[@]}"; do
echo "::add-mask::$DISTRIBUTION"
for i in {1..3}; do aws cloudfront create-invalidation --distribution-id "$DISTRIBUTION" --paths "/dashboard*" && break || sleep 5; done
done
env:
CDN_DISTRIBUTIONS: ${{ secrets.AWS_CLOUD_STAGING_CDN_DISTRIBUTIONS }}
- name: Notify Slack
if: ${{ always() }}
env:
JOB_DEPLOYMENT_KIND: staging
JOB_STATUS: ${{ job.status }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLOUD_DEPLOYMENTS_WEBHOOK_URL }}
SLACK_MENTION_GROUP_ID: ${{ secrets.SLACK_DASHBOARD_GROUP_ID }}
JOB_TITLE: "Dashboard deployment to saleor-master-staging"
run: |
python3 ./.github/workflows/notify/notify-slack.py