|
| 1 | +name: Deploy Staging and E2E |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + types: |
| 8 | + - opened |
| 9 | + - synchronize |
| 10 | + - reopened |
| 11 | + - ready_for_review |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: deploy-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +env: |
| 18 | + CI: true |
| 19 | + |
| 20 | +jobs: |
| 21 | + deploy-staging: |
| 22 | + if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) |
| 23 | + runs-on: ubuntu-latest |
| 24 | + needs: |
| 25 | + - lint-js |
| 26 | + - build-front |
| 27 | + - lint-and-unit-test-django |
| 28 | + - integration-test-django |
| 29 | + steps: |
| 30 | + - name: Configure staging host authenticity |
| 31 | + run: | |
| 32 | + mkdir -p ~/.ssh/ && chmod 700 ~/.ssh/ |
| 33 | + touch ~/.ssh/known_hosts && chmod 600 ~/.ssh/known_hosts |
| 34 | + echo "$SSH_HOSTKEY" > ~/.ssh/known_hosts |
| 35 | + env: |
| 36 | + SSH_HOSTKEY: ${{ secrets.STAGING_HOSTKEY }} |
| 37 | + |
| 38 | + - name: Deploy to staging |
| 39 | + run: | |
| 40 | + eval $(ssh-agent -s) |
| 41 | + echo "$SSH_KEY" | ssh-add - >/dev/null |
| 42 | + ssh "${SSH_USER}@${SSH_HOST}" "deploy ${GITHUB_SHA}" |
| 43 | + env: |
| 44 | + SSH_USER: ${{ secrets.STAGING_USER }} |
| 45 | + SSH_HOST: ${{ secrets.STAGING_HOST }} |
| 46 | + SSH_KEY: ${{ secrets.STAGING_KEY }} |
| 47 | + |
| 48 | + e2e-tests: |
| 49 | + runs-on: ubuntu-latest |
| 50 | + timeout-minutes: 10 |
| 51 | + needs: deploy-staging |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - name: Fetch node_modules |
| 56 | + uses: actions/cache@v4 |
| 57 | + id: fetch-node_modules |
| 58 | + with: |
| 59 | + key: node_modules-${{ runner.os }}-${{ hashFiles('./dashboard/pnpm-lock.yaml') }} |
| 60 | + path: ./dashboard/node_modules |
| 61 | + |
| 62 | + - name: Install pnpm |
| 63 | + uses: pnpm/action-setup@v4 |
| 64 | + with: |
| 65 | + version: 9.15.2 |
| 66 | + |
| 67 | + - uses: actions/setup-node@v4 |
| 68 | + with: |
| 69 | + node-version-file: './dashboard/.nvmrc' |
| 70 | + |
| 71 | + - name: Install Playwright browsers |
| 72 | + run: npx playwright install --with-deps |
| 73 | + working-directory: ./dashboard |
| 74 | + |
| 75 | + - name: Wait for staging deployment to be ready |
| 76 | + run: sleep 180 |
| 77 | + |
| 78 | + - name: Run e2e tests against staging |
| 79 | + run: pnpm e2e |
| 80 | + working-directory: ./dashboard |
| 81 | + env: |
| 82 | + PLAYWRIGHT_TEST_BASE_URL: https://staging.dashboard.kernelci.org:9000 |
0 commit comments