Skip to content

Commit

Permalink
Update GitHub Actions workflows. (#740)
Browse files Browse the repository at this point in the history
This PR was automatically generated by the
update-workflows-ecosystem-providers workflow in the pulumi/ci-mgmt
repo, from commit a33de941cb6b7c0c088739542cfe1104f8aacf3a.
  • Loading branch information
pulumi-bot authored Jan 7, 2025
1 parent c6f63e9 commit 7262183
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ bin/$(TFGEN): provider/*.go provider/go.* .make/upstream
# Apply patches to the upstream submodule, if it exists
upstream: .make/upstream
# Re-run if the upstream commit or the patches change
.make/upstream: $(wildcard patches/*) $(wildcard .git/modules/upstream/HEAD)
.make/upstream: $(wildcard patches/*) $(shell ./upstream.sh file_target)
ifneq ("$(wildcard upstream)","")
./upstream.sh init
endif
Expand Down
21 changes: 21 additions & 0 deletions upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COMMANDS
check_in Write checkedout commits back to patches, add upstream
and patches changes to the git staging area and exit
checkout mode.
file_target Print a file path to depend on in make.
help Print this help message, plus examples.
OPTIONS
Expand Down Expand Up @@ -334,6 +335,23 @@ re-initializing using updated patches and updated upstream base.
EOF
}

# file_target prints a file path to depend on in make to trigger an init when required.
# Also updates the file timestamp if the submodule needs updating.
file_target() {
path=.git/modules/upstream/HEAD
# Don't print a file if it doesn't exist - it's probably not initialized yet.
if [[ ! -f "${path}" ]]; then
exit 0
fi
# If the submodule is changed, touch the file to trigger a re-init.
desired_commit=$(git ls-tree HEAD upstream | cut -d ' ' -f3 | cut -f1 || true)
current_commit=$(cat "${path}")
if [[ "${desired_commit}" != "${current_commit}" ]]; then
touch "${path}"
fi
echo "${path}"
}

if [[ -z ${original_cmd} ]]; then
echo "Error: command is required."
echo
Expand Down Expand Up @@ -372,6 +390,9 @@ case ${original_cmd} in
check_in|checkin)
check_in "$@"
;;
file_target)
file_target "$@"
;;
*)
echo "Error: unknown command \"${original_cmd}\"."
echo
Expand Down

0 comments on commit 7262183

Please sign in to comment.