Skip to content

Commit d85eacb

Browse files
authored
Update GitHub Actions workflows. (#520)
This PR was automatically generated by the update-workflows-ecosystem-providers workflow in the pulumi/ci-mgmt repo, from commit a33de941cb6b7c0c088739542cfe1104f8aacf3a.
1 parent cfa4614 commit d85eacb

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ bin/$(TFGEN): provider/*.go provider/go.* .make/upstream
262262
# Apply patches to the upstream submodule, if it exists
263263
upstream: .make/upstream
264264
# Re-run if the upstream commit or the patches change
265-
.make/upstream: $(wildcard patches/*) $(wildcard .git/modules/upstream/HEAD)
265+
.make/upstream: $(wildcard patches/*) $(shell ./upstream.sh file_target)
266266
ifneq ("$(wildcard upstream)","")
267267
./upstream.sh init
268268
endif

upstream.sh

+21
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ COMMANDS
2323
check_in Write checkedout commits back to patches, add upstream
2424
and patches changes to the git staging area and exit
2525
checkout mode.
26+
file_target Print a file path to depend on in make.
2627
help Print this help message, plus examples.
2728
2829
OPTIONS
@@ -334,6 +335,23 @@ re-initializing using updated patches and updated upstream base.
334335
EOF
335336
}
336337

338+
# file_target prints a file path to depend on in make to trigger an init when required.
339+
# Also updates the file timestamp if the submodule needs updating.
340+
file_target() {
341+
path=.git/modules/upstream/HEAD
342+
# Don't print a file if it doesn't exist - it's probably not initialized yet.
343+
if [[ ! -f "${path}" ]]; then
344+
exit 0
345+
fi
346+
# If the submodule is changed, touch the file to trigger a re-init.
347+
desired_commit=$(git ls-tree HEAD upstream | cut -d ' ' -f3 | cut -f1 || true)
348+
current_commit=$(cat "${path}")
349+
if [[ "${desired_commit}" != "${current_commit}" ]]; then
350+
touch "${path}"
351+
fi
352+
echo "${path}"
353+
}
354+
337355
if [[ -z ${original_cmd} ]]; then
338356
echo "Error: command is required."
339357
echo
@@ -372,6 +390,9 @@ case ${original_cmd} in
372390
check_in|checkin)
373391
check_in "$@"
374392
;;
393+
file_target)
394+
file_target "$@"
395+
;;
375396
*)
376397
echo "Error: unknown command \"${original_cmd}\"."
377398
echo

0 commit comments

Comments
 (0)