-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Selectively build docker image (#47)
Only build image if docker file has been modified. Closes #45
- Loading branch information
Showing
1 changed file
with
25 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 }} | ||
|