Skip to content

Commit

Permalink
infer image tag from config yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomarquezp committed Jun 12, 2024
1 parent 7dde4db commit 63c384c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/hermetic_library_generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:
[ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot"
bash generation/hermetic_library_generation.sh \
--target_branch ${{ github.base_ref }} \
--current_branch ${{ github.head_ref }} \
--image_tag $(cat generation_config.yaml | yq .gapic_generator_version)
--current_branch ${{ github.head_ref }}
env:
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
15 changes: 4 additions & 11 deletions generation/hermetic_library_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ set -e
# The parameters of this script is:
# 1. target_branch, the branch into which the pull request is merged.
# 2. current_branch, the branch with which the pull request is associated.
# 3. image_tag, the tag of gcr.io/cloud-devrel-public-resources/java-library-generation.
# 3. [optional] generation_config, the path to the generation configuration,
# the default value is generation_config.yaml in the repository root.
while [[ $# -gt 0 ]]; do
Expand All @@ -35,10 +34,6 @@ case "${key}" in
current_branch="$2"
shift
;;
--image_tag)
image_tag="$2"
shift
;;
--generation_config)
generation_config="$2"
shift
Expand All @@ -61,14 +56,9 @@ if [ -z "${current_branch}" ]; then
exit 1
fi

if [ -z "${image_tag}" ]; then
echo "missing required argument --image_tag"
exit 1
fi

if [ -z "${generation_config}" ]; then
generation_config=generation_config.yaml
echo "Use default generation config: ${generation_config}"
echo "Using default generation config: ${generation_config}"
fi

workspace_name="/workspace"
Expand All @@ -88,6 +78,9 @@ fi
git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}"
config_diff=$(diff "${generation_config}" "${baseline_generation_config}" || true)

# parse image tag from the generation configuration.
image_tag=$(grep "gapic_generator_version" "${generation_config}" | cut -d ':' -f 2 | xargs)

# run hermetic code generation docker image.
docker run \
--rm \
Expand Down

0 comments on commit 63c384c

Please sign in to comment.