Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selectively build docker image #47

Merged
merged 5 commits into from
Feb 5, 2024
Merged
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
35 changes: 25 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,44 @@ concurrency:
cancel-in-progress: true

jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
# Expose matched filters as job 'packages' output variable
images: ${{ steps.filter.outputs.changes }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code-server: "code-server/**"
rstudio: "rstudio/**"
base-r: "base-r/**"
dev: "dev/**"

push_to_registries:
needs: changes
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
config:
- {name: code-server}
- {name: rstudio}
- {name: base-r}
- {name: dev}
name: ${{ matrix.config.name }}
image: ${{ fromJSON(needs.changes.outputs.images) }}
name: ${{ matrix.image }}
steps:
- name: Check out the repo
uses: actions/[email protected]
- name: Lint Dockerfile
uses: hadolint/[email protected]
with:
dockerfile: "${{ matrix.config.name }}/Dockerfile"
dockerfile: "${{ matrix.image }}/Dockerfile"
- name: Prepare tags
id: docker_meta
uses: docker/[email protected]
with:
images: rapporteket/${{ matrix.config.name }}
images: rapporteket/${{ matrix.image }}
tags: |
type=ref,event=branch
type=ref,event=pr
Expand All @@ -55,8 +70,8 @@ jobs:
- name: Build and push to Docker Hub
uses: docker/[email protected]
with:
context: ./${{ matrix.config.name }}/.
file: ./${{ matrix.config.name }}/Dockerfile
context: ./${{ matrix.image }}/.
file: ./${{ matrix.image }}/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
Expand Down