-
Notifications
You must be signed in to change notification settings - Fork 6
61 lines (52 loc) · 2.36 KB
/
__check_docker_files.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# SPDX-FileCopyrightText: (C) The kokkos-fft development team, see COPYRIGHT.md file
#
# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
# Check if Docker images have changed. In that case, proposes images suffix and
# tag.
name: Check Docker files
on:
workflow_call:
inputs:
event_name:
description: "Event name of the calling workflow"
required: true
type: string
outputs:
docker_files_have_changed:
description: "True if any Docker file was modified"
value: ${{ jobs.check_docker_files.outputs.docker_files_have_changed }}
image_suffix:
description: "Suffix of the images"
value: ${{ jobs.check_docker_files.outputs.image_suffix }}
image_tag:
description: "Tag of the images"
value: ${{ jobs.check_docker_files.outputs.image_tag }}
jobs:
check_docker_files:
runs-on: ubuntu-latest
outputs:
# true if any Docker file was modified in the PR (PR mode) or since last pushed commit (push mode)
docker_files_have_changed: ${{ steps.get_changed_docker_files.outputs.any_changed == 'true' }}
# use "pr" as image name suffix if on PR mode and if any Docker file was modified, otherwise use "main";
# this is intended to avoid a PR to alter Docker images for other PRs or for the main branch
image_suffix: ${{ steps.get_changed_docker_files.outputs.any_changed == 'true' && inputs.event_name == 'pull_request' && 'pr' || 'main' }}
# use "<hash>" as image name tag if on PR mode and if any Docker file was modified, otherwise use "latest";
# this is intended to distinguish PR images from each other
image_tag: ${{ steps.get_changed_docker_files.outputs.any_changed == 'true' && inputs.event_name == 'pull_request' && github.sha || 'latest' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed Docker files
id: get_changed_docker_files
uses: tj-actions/changed-files@v45
with:
files: docker/**/Dockerfile
- name: List changed Docker files
if: ${{ steps.get_changed_docker_files.outputs.any_changed == 'true' }}
env:
ALL_CHANGED_FILES: ${{ steps.get_changed_docker_files.outputs.all_changed_files }}
run: |
for file in $ALL_CHANGED_FILES; do
echo "$file was changed"
done