This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR automation | |
on: [pull_request] | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
initialize-cloud: | |
runs-on: ubuntu-22.04 | |
outputs: | |
POOL_NAME: ${{ steps.cloud_variables.outputs.POOL_NAME }} | |
POOL_INSTANCE: ${{ steps.cloud_variables.outputs.POOL_INSTANCE }} | |
BASE_URL: ${{ steps.cloud_variables.outputs.BASE_URL }} | |
BASE_URL_DOMAIN: ${{ steps.cloud_variables.outputs.BASE_URL_DOMAIN }} | |
API_URL: ${{ steps.cloud_variables.outputs.API_URL }} | |
BACKUP_ID: ${{ steps.cloud_variables.outputs.BACKUP_ID }} | |
BACKUP_VER: ${{ steps.cloud_variables.outputs.BACKUP_VER }} | |
BACKUP_NAME: ${{ steps.cloud_variables.outputs.BACKUP_NAME }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: ./.github/actions | |
- name: Generate variables | |
id: cloud_variables | |
uses: ./.github/actions/prepare-tests-variables | |
with: | |
CLI_TOKEN: ${{ secrets.STAGING_TOKEN }} | |
MODE: pull-request | |
- name: Prepare instances | |
uses: ./.github/actions/prepare-instance | |
with: | |
STRATEGY: reload | |
CLI_TOKEN: ${{ secrets.STAGING_TOKEN }} | |
BASE_URL: ${{ steps.cloud_variables.outputs.BASE_URL }} | |
API_URL: ${{ steps.cloud_variables.outputs.API_URL }} | |
POOL_NAME: ${{ steps.cloud_variables.outputs.POOL_NAME }} | |
POOL_INSTANCE: ${{ steps.cloud_variables.outputs.POOL_INSTANCE }} | |
BACKUP_ID: ${{ steps.cloud_variables.outputs.BACKUP_ID }} | |
deploy-dashboard: | |
if: github.event.pull_request.head.repo.full_name == 'saleor/saleor-dashboard' | |
runs-on: ubuntu-22.04 | |
needs: initialize-cloud | |
permissions: | |
deployments: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: ".nvmrc" | |
- name: Start deployment | |
uses: bobheadxi/deployments@88ce5600046c82542f8246ac287d0a53c461bca3 | |
id: deployment | |
with: | |
step: start | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: ${{ needs.initialize-cloud.outputs.POOL_NAME }} | |
ref: ${{ github.head_ref }} | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-qa-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-qa-${{ env.cache-name }}- | |
${{ runner.os }}-qa- | |
${{ runner.os }}- | |
- name: Install deps | |
run: npm ci | |
- name: Build dashboard | |
env: | |
API_URI: ${{ needs.initialize-cloud.outputs.API_URL }} | |
APPS_MARKETPLACE_API_URI: "https://apps.staging.saleor.io/api/v2/saleor-apps" | |
APP_MOUNT_URI: / | |
STATIC_URL: / | |
IS_CLOUD_INSTANCE: true | |
run: npm run build | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: Deploy to S3 | |
env: | |
AWS_TEST_DEPLOYMENT_BUCKET: ${{ secrets.AWS_TEST_DEPLOYMENT_BUCKET }} | |
BASE_URL_DOMAIN: ${{ needs.initialize-cloud.outputs.BASE_URL_DOMAIN }} | |
run: aws s3 sync ./build/dashboard "s3://${AWS_TEST_DEPLOYMENT_BUCKET}/${BASE_URL_DOMAIN}" | |
- name: Invalidate cache | |
env: | |
AWS_TEST_CF_DIST_ID: ${{ secrets.AWS_TEST_CF_DIST_ID }} | |
BASE_URL_DOMAIN: ${{ needs.initialize-cloud.outputs.BASE_URL_DOMAIN }} | |
run: aws cloudfront create-invalidation --distribution-id "$AWS_TEST_CF_DIST_ID" --paths "/${BASE_URL_DOMAIN}/*" | |
- name: Update deployment status | |
uses: bobheadxi/deployments@88ce5600046c82542f8246ac287d0a53c461bca3 | |
if: always() | |
with: | |
step: finish | |
token: ${{ secrets.GITHUB_TOKEN }} | |
status: ${{ job.status }} | |
env_url: ${{ needs.initialize-cloud.outputs.BASE_URL }} | |
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | |
env: ${{ needs.initialize-cloud.outputs.POOL_NAME }} | |
run-tests: | |
runs-on: ubuntu-22.04 | |
needs: [initialize-cloud, deploy-dashboard] | |
strategy: | |
fail-fast: false | |
matrix: | |
shard: [1/2, 2/2] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run playwright tests | |
uses: ./.github/actions/run-pw-tests | |
with: | |
SHARD: ${{ matrix.shard }} | |
BASE_URL: ${{ needs.initialize-cloud.outputs.BASE_URL }} | |
API_URL: ${{ needs.initialize-cloud.outputs.API_URL }} | |
E2E_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }} | |
E2E_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }} | |
E2E_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }} | |
merge-reports: | |
if: "!cancelled()" | |
needs: run-tests | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Merge playwright reports | |
uses: ./.github/actions/merge-pw-reports |