|
| 1 | +name: Pull Requests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [dev] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build-test-static: |
| 9 | + name: Build and run static analysis |
| 10 | + permissions: |
| 11 | + id-token: write |
| 12 | + contents: read |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/setup-node@v2 |
| 16 | + with: |
| 17 | + node-version: 20 |
| 18 | + |
| 19 | + - uses: actions/checkout@v2 |
| 20 | + |
| 21 | + # Install and cache dependencies. |
| 22 | + - uses: actions/cache@v4 |
| 23 | + id: yarn-cache |
| 24 | + with: |
| 25 | + path: .yarn/cache |
| 26 | + key: yarn-${{ hashFiles('**/yarn.lock') }} |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: yarn --immutable |
| 30 | + |
| 31 | + # Run static code analysis. |
| 32 | + - name: Check code formatting |
| 33 | + run: yarn format |
| 34 | + |
| 35 | + - name: ESLint |
| 36 | + run: yarn lint |
| 37 | + |
| 38 | + deploy: |
| 39 | + name: Deploy to PR environment |
| 40 | + permissions: |
| 41 | + id-token: write |
| 42 | + contents: read |
| 43 | + pull-requests: write |
| 44 | + needs: build-test-static |
| 45 | + runs-on: ubuntu-latest |
| 46 | + # We use "dev" environment variables here, but, if needed, a separate set of |
| 47 | + # variables and a separate pull requests-related AWS account can be used too. |
| 48 | + env: |
| 49 | + NODE_OPTIONS: --max_old_space_size=4096 |
| 50 | + AWS_REGION: ${{ secrets.DEV_AWS_REGION }} |
| 51 | + OPENSEARCH_DOMAIN_NAME: ${{ secrets.DEV_OPENSEARCH_DOMAIN_NAME }} |
| 52 | + OPENSEARCH_INDEX_PREFIX: pr${{ github.event.pull_request.number }} |
| 53 | + PULUMI_SECRETS_PROVIDER: ${{ secrets.DEV_PULUMI_SECRETS_PROVIDER }} |
| 54 | + PULUMI_CONFIG_PASSPHRASE: ${{ secrets.DEV_PULUMI_CONFIG_PASSPHRASE }} |
| 55 | + WEBINY_PULUMI_BACKEND: ${{ secrets.DEV_WEBINY_PULUMI_BACKEND_PULL_REQUESTS }} |
| 56 | + WEBINY_PROJECT_ID: ${{ secrets.DEV_WEBINY_PROJECT_ID }} |
| 57 | + WEBINY_PROJECT_API_KEY: ${{ secrets.DEV_WEBINY_PROJECT_API_KEY }} |
| 58 | + steps: |
| 59 | + - name: Configure AWS Credentials |
| 60 | + uses: aws-actions/configure-aws-credentials@v4 |
| 61 | + with: |
| 62 | + role-to-assume: ${{ secrets.DEV_AWS_ROLE_ARN }} |
| 63 | + aws-region: ${{ secrets.DEV_AWS_REGION }} |
| 64 | + |
| 65 | + - uses: actions/setup-node@v2 |
| 66 | + with: |
| 67 | + node-version: 20 |
| 68 | + |
| 69 | + - uses: actions/checkout@v2 |
| 70 | + |
| 71 | + # Install and cache dependencies. |
| 72 | + - uses: actions/cache@v4 |
| 73 | + id: yarn-cache |
| 74 | + with: |
| 75 | + path: .yarn/cache |
| 76 | + key: yarn-${{ hashFiles('**/yarn.lock') }} |
| 77 | + |
| 78 | + - name: Install dependencies |
| 79 | + run: yarn --immutable |
| 80 | + |
| 81 | + # Deploy to a short-lived environment (will be destroyed once the PR is closed). |
| 82 | + - name: Deploy core |
| 83 | + run: yarn webiny deploy core --env pr${{ github.event.pull_request.number }} |
| 84 | + |
| 85 | + - name: Deploy API |
| 86 | + run: yarn webiny deploy api --env pr${{ github.event.pull_request.number }} |
| 87 | + |
| 88 | + - name: Deploy Admin |
| 89 | + run: yarn webiny deploy admin --env pr${{ github.event.pull_request.number }} |
| 90 | + |
| 91 | + # Add additional steps if needed. For example, if you have additional E2E |
| 92 | + # tests done with Cypress (https://www.cypress.io/), you can run them here. |
0 commit comments