|
| 1 | +name: ci-cd |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + - development |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - '*' |
| 10 | + |
| 11 | +env: |
| 12 | + PUPPETEER_SKIP_DOWNLOAD: 'true' |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.run_number || github.event.pull_request.number }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + id-token: write |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + name: Build |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Checkout code |
| 28 | + uses: actions/checkout@v5 |
| 29 | + |
| 30 | + - name: Setup Node.js |
| 31 | + uses: actions/setup-node@v6 |
| 32 | + with: |
| 33 | + node-version: 'lts/*' |
| 34 | + cache: 'npm' |
| 35 | + |
| 36 | + - name: npm ci |
| 37 | + run: npm ci |
| 38 | + |
| 39 | + - name: Setup Chrome |
| 40 | + uses: browser-actions/setup-chrome@19ae4b339ee18925ab85cf12c1041150ea4a44c8 # v1 |
| 41 | + with: |
| 42 | + chrome-version: '125' |
| 43 | + - name: Set CHROME_BIN |
| 44 | + run: echo "CHROME_BIN=$(which chrome)" >> $GITHUB_ENV |
| 45 | + |
| 46 | + - name: npm test-ts-decls |
| 47 | + run: npm run test-ts-decls |
| 48 | + |
| 49 | + - name: npm check |
| 50 | + run: npm run check |
| 51 | + |
| 52 | + - name: npm test |
| 53 | + run: npm run test |
| 54 | + |
| 55 | + - name: npm build |
| 56 | + run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") npm run build |
| 57 | + |
| 58 | + - name: Store assets |
| 59 | + if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/development' || github.ref == 'refs/heads/main') }} |
| 60 | + uses: actions/upload-artifact@v5 |
| 61 | + with: |
| 62 | + name: assets |
| 63 | + path: umd/ |
| 64 | + retention-days: 1 |
| 65 | + |
| 66 | + upload-stage: |
| 67 | + name: Upload assets |
| 68 | + runs-on: ubuntu-latest |
| 69 | + needs: build |
| 70 | + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }} |
| 71 | + strategy: |
| 72 | + matrix: |
| 73 | + environment: |
| 74 | + - stage |
| 75 | + include: |
| 76 | + - environment: stage |
| 77 | + account_id: "079419646996" |
| 78 | + bucket: split-public-stage |
| 79 | + |
| 80 | + steps: |
| 81 | + - name: Download assets |
| 82 | + uses: actions/download-artifact@v6 |
| 83 | + with: |
| 84 | + name: assets |
| 85 | + path: umd |
| 86 | + |
| 87 | + - name: Display structure of assets |
| 88 | + run: ls -R |
| 89 | + working-directory: umd |
| 90 | + |
| 91 | + - name: Configure AWS credentials |
| 92 | + uses: aws-actions/configure-aws-credentials@v4 |
| 93 | + with: |
| 94 | + role-to-assume: arn:aws:iam::${{ matrix.account_id }}:role/gha-public-assets-role |
| 95 | + aws-region: us-east-1 |
| 96 | + |
| 97 | + - name: Upload to S3 |
| 98 | + run: aws s3 sync $SOURCE_DIR s3://$BUCKET/$DEST_DIR $ARGS |
| 99 | + env: |
| 100 | + BUCKET: ${{ matrix.bucket }} |
| 101 | + SOURCE_DIR: ./umd |
| 102 | + DEST_DIR: sdk |
| 103 | + ARGS: --acl public-read --follow-symlinks --cache-control max-age=31536000,public |
| 104 | + |
| 105 | + upload-prod: |
| 106 | + name: Upload assets |
| 107 | + runs-on: ubuntu-latest |
| 108 | + needs: build |
| 109 | + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} |
| 110 | + strategy: |
| 111 | + matrix: |
| 112 | + environment: |
| 113 | + - prod |
| 114 | + include: |
| 115 | + - environment: prod |
| 116 | + account_id: "825951051969" |
| 117 | + bucket: split-public |
| 118 | + |
| 119 | + steps: |
| 120 | + - name: Download assets |
| 121 | + uses: actions/download-artifact@v6 |
| 122 | + with: |
| 123 | + name: assets |
| 124 | + path: umd |
| 125 | + |
| 126 | + - name: Display structure of assets |
| 127 | + run: ls -R |
| 128 | + working-directory: umd |
| 129 | + |
| 130 | + - name: Configure AWS credentials |
| 131 | + uses: aws-actions/configure-aws-credentials@v4 |
| 132 | + with: |
| 133 | + role-to-assume: arn:aws:iam::${{ matrix.account_id }}:role/gha-public-assets-role |
| 134 | + aws-region: us-east-1 |
| 135 | + |
| 136 | + - name: Upload to S3 |
| 137 | + run: aws s3 sync $SOURCE_DIR s3://$BUCKET/$DEST_DIR $ARGS |
| 138 | + env: |
| 139 | + BUCKET: ${{ matrix.bucket }} |
| 140 | + SOURCE_DIR: ./umd |
| 141 | + DEST_DIR: sdk |
| 142 | + ARGS: --acl public-read --follow-symlinks --cache-control max-age=31536000,public |
0 commit comments