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

feat: embed path filtering into Argus builder workflow #268

Merged
merged 6 commits into from
May 30, 2024
Merged
Changes from 2 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
30 changes: 29 additions & 1 deletion .github/workflows/argus-docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ on:
description: 'JSON array of images to build (required keys: dockerfile, context, name, platform)'
required: true
type: string
path_filters:
description: 'Path to the configuration file or YAML string with filters definition'
required: false
type: string
default: '**/*'
path_filters_base:
description: |
Git reference (e.g. branch name) against which the changes will be detected. Defaults to repository default branch (e.g. master).
hspitzley-czi marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update description

If it references same branch it was pushed to, changes are detected against the most recent commit before the push.
This option is ignored if action is triggered by pull_request event.
required: false
type: string

jobs:
prep:
Expand All @@ -21,13 +33,29 @@ jobs:
image-tag: ${{ steps.build-tags.outputs.IMAGE_TAG }}
images: ${{ steps.parse-images.outputs.images }}
envs: ${{ steps.parse-envs.outputs.envs }}
run_build: ${{ steps.filter.outputs.run_on }}
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Parse filters
id: parse_filters
uses: actions/github-script@v7
with:
script: |
const filters = `${{ inputs.path_filters }}`.split(',').map(f => f.trim());
const filtersStr = "run_on:\n" + filters.map(f => ` - ${f}`).join('\n');
core.setOutput('filters', filtersStr);
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
${{ steps.parse_filters.outputs.filters }}
base: ${{ inputs.path_filters_base }}
list-files: json
- name: Get build tag
id: build-tags
run: |
Expand Down Expand Up @@ -55,7 +83,7 @@ jobs:
- ${{ matrix.image.platform == 'linux/amd64' && 'X64' || 'ARM64' }}
env:
IMAGE_TAG: ${{ needs.prep.outputs.image-tag }}
if: needs.prep.outputs.image-tag != '' && needs.prep.outputs.image-tag != 'sha-' && needs.prep.outputs.images != '[]'
if: needs.prep.outputs.run_build == 'true' && needs.prep.outputs.image-tag != '' && needs.prep.outputs.image-tag != 'sha-' && needs.prep.outputs.images != '[]'
permissions:
id-token: write
contents: read
Expand Down
Loading