-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PSCE-309 - Adds sync-upstreams GitHub Action and usage documentation (#…
…148) * refactor: updates entrypoint bash scripts to use common.sh To reduce code duplication in the bash script, common logic is added to common.sh for reuse. Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com> * feat: adds sync-upstreams action and documentation Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com> * fix: uses abs path to common.sh in entrypoint scripts The working directory is subject to change and the entrypoint scripts need to source `common.sh` from the location in the container. Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com> * chore: updates README.md files based on PR feedback Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com> --------- Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
- Loading branch information
Showing
9 changed files
with
353 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# shellcheck disable=SC2148 | ||
|
||
# common.sh | ||
# This file is sourced by other scripts and contains common functions | ||
|
||
# Manage newest git versions (related to CVE https://github.blog/2022-04-12-git-security-vulnerability-announced/) | ||
# | ||
function set_git_safe_directory() { | ||
if [[ -z "${GITHUB_WORKSPACE+x}" ]]; then | ||
echo "Setting git safe.directory default: /github/workspace ..." | ||
git config --global --add safe.directory /github/workspace | ||
else | ||
echo "Setting git safe.directory GITHUB_WORKSPACE: $GITHUB_WORKSPACE ..." | ||
git config --global --add safe.directory "$GITHUB_WORKSPACE" | ||
fi | ||
|
||
if [[ -z "${INPUT_REPOSITORY+x}" ]]; then | ||
echo "Skipping setting working directory as safe directory" | ||
else | ||
echo "Setting git safe.directory default: $INPUT_REPOSITORY ..." | ||
git config --global --add safe.directory "$INPUT_REPOSITORY" | ||
fi | ||
} | ||
|
||
# Execute the command and set the output variables for GitHub Actions | ||
function execute_command() { | ||
local command=$1 | ||
exec 3>&1 | ||
output=$(eval "$command" > >(tee /dev/fd/3) 2>&1) | ||
|
||
commit=$(echo "$output" | grep "Commit Hash:" | sed 's/.*: //') | ||
|
||
if [ -n "$commit" ]; then | ||
echo "changes=true" >> "$GITHUB_OUTPUT" | ||
echo "commit=$commit" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "changes=false" >> "$GITHUB_OUTPUT" | ||
fi | ||
|
||
pr_number=$(echo "$output" | grep "Pull Request Number:" | sed 's/.*: //') | ||
|
||
if [ -n "$pr_number" ]; then | ||
echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT" | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.