Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
- ruby/Dockerfile
- .github/workflows/ruby.yml
workflow_dispatch:
inputs:
force:
description: Rebuild all images
type: boolean
default: false

env:
REGISTRY: ghcr.io
Expand All @@ -37,14 +42,38 @@ jobs:

- uses: docker/setup-buildx-action@v4

- name: Check if Dockerfile changed
id: dockerfile
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE="${{ github.event.pull_request.base.sha }}"
else
BASE="${{ github.event.before }}"
fi
if git diff --name-only "$BASE" "${{ github.sha }}" -- ruby/Dockerfile | grep -q .; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi

- name: Check if image exists
id: check
run: |
if docker buildx imagetools inspect "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.ruby-version }}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi

- uses: docker/login-action@v4
if: github.event_name != 'pull_request'
if: github.event_name != 'pull_request' && (steps.check.outputs.exists != 'true' || steps.dockerfile.outputs.changed == 'true' || (github.event_name == 'workflow_dispatch' && inputs.force))
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/build-push-action@v7
if: steps.check.outputs.exists != 'true' || steps.dockerfile.outputs.changed == 'true' || (github.event_name == 'workflow_dispatch' && inputs.force)
with:
context: ruby
platforms: linux/amd64,linux/arm64
Expand Down
Loading