diff --git a/.github/scripts/plugin-helper-gh-pr-create.sh b/.github/scripts/plugin-helper-gh-pr-create.sh index 4e8ba06c54..ca52da3407 100755 --- a/.github/scripts/plugin-helper-gh-pr-create.sh +++ b/.github/scripts/plugin-helper-gh-pr-create.sh @@ -1,20 +1,14 @@ #!/usr/bin/env bash -# this script expects the following env vars to be set -# - GITHUB_TOKEN -# - PLUGIN_REPO -# - VAULT_BRANCH -# - PLUGIN_BRANCH -# - RUN_ID +set -e -echo "ENVS:" -if [ -z $GITHUB_TOKEN ]; then - echo "github token is unset?" -fi -echo "$PLUGIN_REPO" -echo "$VAULT_BRANCH" -echo "$PLUGIN_BRANCH" -echo "$RUN_ID" +# this script expects the following env vars to be set +# error if these are not set +[ ${GITHUB_TOKEN:?} ] +[ ${PLUGIN_REPO:?} ] +[ ${VAULT_BRANCH:?} ] +[ ${PLUGIN_BRANCH:?} ] +[ ${RUN_ID:?} ] # we are using the GH API directly so that we can get the resluting # PR URL from the JSON response @@ -31,19 +25,23 @@ resp=$(curl -SL \ "title":"[DO NOT MERGE]: $PLUGIN_REPO Automated plugin update check", "body":"Updates $PLUGIN_REPO to verify vault CI. Full log: https://github.com/hashicorp/vault/actions/runs/$RUN_ID", "head":"$VAULT_BRANCH", - "base":"master", - "label": "dependencies,pr/no-changelog,pr/no-milestone", + "base":"main", "reviewer": "$reviewers", } EOF ) ) +echo "captured response:" echo "$resp" | jq . # get Vault PR number +vault_pr_num=$(echo "$resp" | jq '.number') vault_pr_url=$(echo "$resp" | jq '.html_url') -echo "$vault_pr_url" +echo "Vault PR number: $vault_pr_url" + +# add labels to Vault PR +gh pr edit $vault_pr_num ---add-label "dependencies,pr/no-changelong,pr/no-milestone" --repo hashicorp/vault # get Plugin PR number plugin_pr_num=$(gh pr list --head "$PLUGIN_BRANCH" --json number --repo hashicorp/$PLUGIN_REPO -q '.[0].number')