Skip to content

Commit 3cc32f3

Browse files
[IMP] Push PR test image to make easier test changes
1 parent b6a70e6 commit 3cc32f3

File tree

1 file changed

+69
-2
lines changed

1 file changed

+69
-2
lines changed

.github/workflows/ci.yml

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ jobs:
4040
uses: actions/setup-python@v4
4141
with:
4242
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
4347
- name: Generate cache key CACHE
4448
run:
4549
echo "CACHE=${{ secrets.CACHE_DATE }} ${{ runner.os }} $(python -VV |
@@ -59,6 +63,10 @@ jobs:
5963
# Run tests
6064
- run: poetry run pytest --prebuild
6165
build-push:
66+
permissions:
67+
contents: read
68+
packages: write
69+
pull-requests: write
6270
runs-on: ubuntu-24.04
6371
services:
6472
registry:
@@ -98,11 +106,50 @@ jobs:
98106
- name: Compute image name
99107
id: image_name_compute
100108
run: |
109+
owner="${GITHUB_REPOSITORY_OWNER,,}"
110+
repo="${GITHUB_REPOSITORY#*/}"
101111
if [ "${{ matrix.target }}" = "base" ]; then
102-
echo "::set-output name=image_name::${{ env.DOCKER_IMAGE_NAME }}"
112+
echo "image_name=${owner}/${repo}" >> "$GITHUB_OUTPUT"
103113
else
104-
echo "::set-output name=image_name::${{ env.DOCKER_IMAGE_NAME }}-${{ matrix.target }}"
114+
echo "image_name=${owner}/${repo}-${{ matrix.target }}" >> "$GITHUB_OUTPUT"
105115
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: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
127+
uses: docker/login-action@v3
128+
with:
129+
registry: ghcr.io
130+
username: ${{ secrets.BOT_LOGIN }}
131+
password: ${{ secrets.BOT_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+
106153
- name: Docker meta for local images
107154
id: docker_meta_local
108155
uses: docker/metadata-action@v5
@@ -168,3 +215,23 @@ jobs:
168215
labels: ${{ steps.docker_meta_public.outputs.labels }}
169216
tags: ${{ steps.docker_meta_public.outputs.tags }}
170217
target: ${{ matrix.target }}
218+
219+
commentless-summary:
220+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
221+
runs-on: ubuntu-24.04
222+
needs: build-push
223+
steps:
224+
- name: Write to job summary
225+
run: |
226+
{
227+
echo "## Test images pushed to GHCR"
228+
for t in base docker docker-s3 postgres postgres-s3 postgres-multi s3; do
229+
if [ "$t" = base ]; then
230+
img="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${GITHUB_REPOSITORY#*/}"
231+
else
232+
img="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${GITHUB_REPOSITORY#*/}-$t"
233+
fi
234+
echo "- **$t** → \`$img:test-pr${{ github.event.number }}\`"
235+
done
236+
} >> "$GITHUB_STEP_SUMMARY"
237+

0 commit comments

Comments
 (0)