|
4 | 4 | push: |
5 | 5 | branches: [ main ] |
6 | 6 | pull_request: |
7 | | - branches: [ main ] |
| 7 | + types: [opened, synchronize, reopened, ready_for_review] |
| 8 | + branches: [ '**' ] |
8 | 9 |
|
9 | 10 | jobs: |
10 | | - test: |
| 11 | + # default permissions: least privilege; override where needed |
| 12 | + lint-and-unit: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + - uses: oven-sh/setup-bun@v1 |
| 19 | + with: |
| 20 | + bun-version: 1.3.2 |
| 21 | + - name: Install deps |
| 22 | + run: bun install --frozen-lockfile |
| 23 | + - name: Lint |
| 24 | + run: bun run lint |
| 25 | + - name: Unit + integration tests |
| 26 | + run: bun test |
| 27 | + |
| 28 | + api-smoke-v2: |
11 | 29 | runs-on: ubuntu-latest |
| 30 | + needs: lint-and-unit |
| 31 | + permissions: |
| 32 | + contents: read |
12 | 33 | steps: |
13 | | - - uses: actions/checkout@v3 |
14 | | - |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + - uses: oven-sh/setup-bun@v1 |
| 36 | + with: |
| 37 | + bun-version: 1.3.2 |
| 38 | + - name: Install deps |
| 39 | + run: bun install --frozen-lockfile |
| 40 | + - name: Run API smoke (v2) |
| 41 | + run: | |
| 42 | + chmod +x ./scripts/test-api.sh |
| 43 | + ./scripts/test-api.sh --url http://localhost:3000 |
| 44 | + env: |
| 45 | + PORT: 3000 |
| 46 | + |
| 47 | + docker-test: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + needs: lint-and-unit |
| 50 | + permissions: |
| 51 | + contents: read |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
15 | 54 | - name: Set up Docker Buildx |
16 | 55 | uses: docker/setup-buildx-action@v2 |
17 | | - |
18 | | - - name: Run Docker test script |
| 56 | + - name: Run Docker test script (v2-focused) |
19 | 57 | run: | |
20 | 58 | chmod +x ./scripts/test-mapeo-config.sh |
21 | 59 | ./scripts/test-mapeo-config.sh |
| 60 | +
|
| 61 | + docker-publish-pr: |
| 62 | + if: github.event_name == 'pull_request' |
| 63 | + runs-on: ubuntu-latest |
| 64 | + needs: docker-test |
| 65 | + permissions: |
| 66 | + contents: read |
| 67 | + packages: write |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v4 |
| 70 | + - name: Log in to GHCR |
| 71 | + uses: docker/login-action@v2 |
| 72 | + with: |
| 73 | + registry: ghcr.io |
| 74 | + username: ${{ github.actor }} |
| 75 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + - name: Set up Docker Buildx |
| 77 | + uses: docker/setup-buildx-action@v2 |
| 78 | + - name: Build and push PR image |
| 79 | + uses: docker/build-push-action@v4 |
| 80 | + with: |
| 81 | + context: . |
| 82 | + push: true |
| 83 | + tags: ghcr.io/${{ github.repository }}:pr-${{ github.event.number }} |
| 84 | + cache-from: type=gha |
| 85 | + cache-to: type=gha,mode=max |
0 commit comments