Skip to content

Commit 8f1a14d

Browse files
committed
conditional CI build
1 parent f4cb235 commit 8f1a14d

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,44 @@ jobs:
8282
- name: Build release
8383
run: cargo build --release
8484

85+
docker-build:
86+
name: Build and Push Docker Test Image
87+
runs-on: ubuntu-latest
88+
# Only run on pushes to main when Docker files change
89+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
90+
permissions:
91+
contents: read
92+
packages: write
93+
steps:
94+
- uses: actions/checkout@v4
95+
96+
- name: Check for Docker file changes
97+
uses: dorny/paths-filter@v3
98+
id: changes
99+
with:
100+
filters: |
101+
docker:
102+
- 'Dockerfile'
103+
- 'docker-compose.yml'
104+
105+
- name: Log in to GitHub Container Registry
106+
if: steps.changes.outputs.docker == 'true'
107+
uses: docker/login-action@v3
108+
with:
109+
registry: ghcr.io
110+
username: ${{ github.actor }}
111+
password: ${{ secrets.GITHUB_TOKEN }}
112+
113+
- name: Build and push Docker image
114+
if: steps.changes.outputs.docker == 'true'
115+
run: |
116+
docker compose build
117+
docker compose push
118+
85119
test-shellspec-linux:
86120
name: ShellSpec Tests (Linux)
87121
runs-on: ubuntu-latest
88-
needs: test-rust
122+
needs: [test-rust, docker-build]
89123
steps:
90124
- uses: actions/checkout@v4
91125

@@ -103,11 +137,19 @@ jobs:
103137
target
104138
key: ubuntu-latest-cargo-${{ hashFiles('**/Cargo.lock') }}
105139

140+
- name: Log in to GitHub Container Registry
141+
uses: docker/login-action@v3
142+
with:
143+
registry: ghcr.io
144+
username: ${{ github.actor }}
145+
password: ${{ secrets.GITHUB_TOKEN }}
146+
106147
- name: Build Ruby Butler
107148
run: cargo build --release
108149

109-
- name: Build Docker test image
110-
run: make docker
150+
- name: Try to pull Docker test image
151+
run: |
152+
docker compose pull
111153
112154
- name: Make shellspec executable
113155
run: chmod +x ./shellspec

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
services:
55
rb-test:
66
build: .
7-
image: rb-test
7+
image: ghcr.io/rubyelders/ruby-butler-test:latest
88
volumes:
99
# Ruby Butler binary (read-only)
1010
- ./target/release/rb:/app/rb:ro

shellspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
exec docker compose run --rm rb-test shellspec "$@"
2+
exec docker compose run --rm ghcr.io/rubyelders/ruby-butler-test shellspec "$@"

0 commit comments

Comments
 (0)