|
40 | 40 | uses: actions/setup-python@v4
|
41 | 41 | with:
|
42 | 42 | python-version: ${{ matrix.python }}
|
| 43 | + - name: Install system deps for duplicity build |
| 44 | + run: | |
| 45 | + sudo apt-get update |
| 46 | + sudo apt-get install -y librsync-dev |
43 | 47 | - name: Generate cache key CACHE
|
44 | 48 | run:
|
45 | 49 | echo "CACHE=${{ secrets.CACHE_DATE }} ${{ runner.os }} $(python -VV |
|
|
59 | 63 | # Run tests
|
60 | 64 | - run: poetry run pytest --prebuild
|
61 | 65 | build-push:
|
| 66 | + permissions: |
| 67 | + contents: read |
| 68 | + packages: write |
| 69 | + pull-requests: write |
62 | 70 | runs-on: ubuntu-24.04
|
63 | 71 | services:
|
64 | 72 | registry:
|
@@ -98,11 +106,51 @@ jobs:
|
98 | 106 | - name: Compute image name
|
99 | 107 | id: image_name_compute
|
100 | 108 | run: |
|
| 109 | + owner="${GITHUB_REPOSITORY_OWNER,,}" |
| 110 | + repo="${GITHUB_REPOSITORY#*/}" |
101 | 111 | if [ "${{ matrix.target }}" = "base" ]; then
|
102 |
| - echo "::set-output name=image_name::${{ env.DOCKER_IMAGE_NAME }}" |
| 112 | + echo "image_name=${owner}/${repo}" >> "$GITHUB_OUTPUT" |
103 | 113 | else
|
104 |
| - echo "::set-output name=image_name::${{ env.DOCKER_IMAGE_NAME }}-${{ matrix.target }}" |
| 114 | + echo "image_name=${owner}/${repo}-${{ matrix.target }}" >> "$GITHUB_OUTPUT" |
105 | 115 | fi
|
| 116 | + - name: Docker meta for PR test image |
| 117 | + if: ${{ github.event_name == 'pull_request' }} |
| 118 | + id: docker_meta_pr |
| 119 | + uses: docker/metadata-action@v5 |
| 120 | + with: |
| 121 | + images: ghcr.io/${{ steps.image_name_compute.outputs.image_name }} |
| 122 | + tags: | |
| 123 | + type=raw,value=test-pr${{ github.event.number }} |
| 124 | +
|
| 125 | + - name: Login to GHCR for PR (same-repo only) |
| 126 | + if: |
| 127 | + ${{ github.event_name == 'pull_request' && |
| 128 | + github.event.pull_request.head.repo.full_name == github.repository }} |
| 129 | + uses: docker/login-action@v3 |
| 130 | + with: |
| 131 | + registry: ghcr.io |
| 132 | + username: ${{ secrets.BOT_LOGIN }} |
| 133 | + password: ${{ secrets.BOT_TOKEN }} |
| 134 | + |
| 135 | + - name: Build & push PR test image (GHCR) |
| 136 | + if: |
| 137 | + ${{ github.event_name == 'pull_request' && |
| 138 | + github.event.pull_request.head.repo.full_name == github.repository }} |
| 139 | + uses: docker/build-push-action@v5 |
| 140 | + with: |
| 141 | + context: . |
| 142 | + file: ./Dockerfile |
| 143 | + platforms: | |
| 144 | + linux/amd64 |
| 145 | + linux/arm64/v8 |
| 146 | + target: ${{ matrix.target }} |
| 147 | + push: true |
| 148 | + load: false |
| 149 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 150 | + cache-to: type=local,dest=/tmp/.buildx-cache,mode=max |
| 151 | + labels: ${{ steps.docker_meta_pr.outputs.labels }} |
| 152 | + tags: ${{ steps.docker_meta_pr.outputs.tags }} |
| 153 | + |
106 | 154 | - name: Docker meta for local images
|
107 | 155 | id: docker_meta_local
|
108 | 156 | uses: docker/metadata-action@v5
|
@@ -168,3 +216,24 @@ jobs:
|
168 | 216 | labels: ${{ steps.docker_meta_public.outputs.labels }}
|
169 | 217 | tags: ${{ steps.docker_meta_public.outputs.tags }}
|
170 | 218 | target: ${{ matrix.target }}
|
| 219 | + |
| 220 | + commentless-summary: |
| 221 | + if: |
| 222 | + ${{ github.event_name == 'pull_request' && |
| 223 | + github.event.pull_request.head.repo.full_name == github.repository }} |
| 224 | + runs-on: ubuntu-24.04 |
| 225 | + needs: build-push |
| 226 | + steps: |
| 227 | + - name: Write to job summary |
| 228 | + run: | |
| 229 | + { |
| 230 | + echo "## Test images pushed to GHCR" |
| 231 | + for t in base docker docker-s3 postgres postgres-s3 postgres-multi s3; do |
| 232 | + if [ "$t" = base ]; then |
| 233 | + img="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${GITHUB_REPOSITORY#*/}" |
| 234 | + else |
| 235 | + img="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${GITHUB_REPOSITORY#*/}-$t" |
| 236 | + fi |
| 237 | + echo "- **$t** → \`$img:test-pr${{ github.event.number }}\`" |
| 238 | + done |
| 239 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments