|
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:
|
@@ -99,10 +107,65 @@ jobs:
|
99 | 107 | id: image_name_compute
|
100 | 108 | run: |
|
101 | 109 | if [ "${{ matrix.target }}" = "base" ]; then
|
102 |
| - echo "::set-output name=image_name::${{ env.DOCKER_IMAGE_NAME }}" |
| 110 | + echo "image_name=${{ env.DOCKER_IMAGE_NAME }}" >> "$GITHUB_OUTPUT" |
103 | 111 | else
|
104 |
| - echo "::set-output name=image_name::${{ env.DOCKER_IMAGE_NAME }}-${{ matrix.target }}" |
| 112 | + echo "image_name=${{ env.DOCKER_IMAGE_NAME }}-${{ matrix.target }}" >> "$GITHUB_OUTPUT" |
105 | 113 | fi
|
| 114 | + - name: Docker meta for PR test image |
| 115 | + if: ${{ github.event_name == 'pull_request' }} |
| 116 | + id: docker_meta_pr |
| 117 | + uses: docker/metadata-action@v5 |
| 118 | + with: |
| 119 | + images: ghcr.io/${{ steps.image_name_compute.outputs.image_name }} |
| 120 | + tags: | |
| 121 | + type=raw,value=test-pr${{ github.event.number }} |
| 122 | +
|
| 123 | + - name: Login to GHCR for PR (same-repo only) |
| 124 | + if: |
| 125 | + ${{ github.event_name == 'pull_request' && |
| 126 | + github.event.pull_request.head.repo.full_name == github.repository }} |
| 127 | + uses: docker/login-action@v3 |
| 128 | + with: |
| 129 | + registry: ghcr.io |
| 130 | + username: ${{ github.actor }} |
| 131 | + password: ${{ github.token }} |
| 132 | + |
| 133 | + - name: Build & push PR test image (GHCR) |
| 134 | + if: |
| 135 | + ${{ github.event_name == 'pull_request' && |
| 136 | + github.event.pull_request.head.repo.full_name == github.repository }} |
| 137 | + uses: docker/build-push-action@v5 |
| 138 | + with: |
| 139 | + context: . |
| 140 | + file: ./Dockerfile |
| 141 | + platforms: | |
| 142 | + linux/amd64 |
| 143 | + linux/arm64/v8 |
| 144 | + target: ${{ matrix.target }} |
| 145 | + push: true |
| 146 | + load: false |
| 147 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 148 | + cache-to: type=local,dest=/tmp/.buildx-cache,mode=max |
| 149 | + labels: ${{ steps.docker_meta_pr.outputs.labels }} |
| 150 | + tags: ${{ steps.docker_meta_pr.outputs.tags }} |
| 151 | + |
| 152 | + - name: Comment PR with test image tag (optional) |
| 153 | + if: |
| 154 | + ${{ github.event_name == 'pull_request' && |
| 155 | + github.event.pull_request.head.repo.full_name == github.repository }} |
| 156 | + uses: actions/github-script@v7 |
| 157 | + with: |
| 158 | + script: | |
| 159 | + const img = 'ghcr.io/${{ steps.image_name_compute.outputs.image_name }}'; |
| 160 | + const tag = 'test-pr${{ github.event.number }}'; |
| 161 | + const target = '${{ matrix.target }}'; |
| 162 | + await github.rest.issues.createComment({ |
| 163 | + owner: context.repo.owner, |
| 164 | + repo: context.repo.repo, |
| 165 | + issue_number: context.issue.number, |
| 166 | + body: `Test image for **${target}**:\n\`${img}:${tag}\`` |
| 167 | + }); |
| 168 | +
|
106 | 169 | - name: Docker meta for local images
|
107 | 170 | id: docker_meta_local
|
108 | 171 | uses: docker/metadata-action@v5
|
|
0 commit comments