Skip to content

Commit

Permalink
Enforce .dockerignore for Docker projects
Browse files Browse the repository at this point in the history
change-type: patch
  • Loading branch information
ab77 committed Jan 29, 2025
1 parent 1183fff commit b101101
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/flowzone.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions flowzone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,25 @@ jobs:
# https://github.com/actions/checkout
- *shallowCheckout

# enforce .dockerignore requirement and warn (for now) if .git isn't excluded
- name: Check for .dockerignore
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
env:
WORKDIR: ${{ inputs.working_directory }}
with:
script: |
const fs = require('fs');
fs.readFile(`${process.env.WORKDIR}/.dockerignore`, 'utf8', (err, data) => {
if (err) {
console.error('Docker builds require .dockerignore file.');
process.exit(1);
} else {
if (!data.split('\n').includes('.git')) {
console.warn('.dockerignore should exclude .git directory/folder for security reasons.');
}
}
});
- <<: *setupBuildx
with:
# pin to a known working version because v0.10.x will
Expand Down
Empty file added tests/.dockerignore
Empty file.

0 comments on commit b101101

Please sign in to comment.