Skip to content

Commit

Permalink
plugin automation: use gh cli and add labels (#21657)
Browse files Browse the repository at this point in the history
* plugin automation: use gh cli and add labels

* remove unneeded fields

* reorder steps

* remove comment

* fix typo

* add some validation
  • Loading branch information
fairclothjm authored Jul 12, 2023
1 parent a98c0d9 commit c121728
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 52 deletions.
50 changes: 0 additions & 50 deletions .github/scripts/plugin-helper-gh-pr-create.sh

This file was deleted.

48 changes: 46 additions & 2 deletions .github/workflows/plugin-update-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
git push -f origin ${{ github.ref_name }}:"$VAULT_BRANCH"
- name: Open pull request if needed
id: pr
if: steps.changes.outputs.count > 0
env:
GITHUB_TOKEN: ${{secrets.ELEVATED_GITHUB_TOKEN}}
Expand All @@ -59,9 +60,52 @@ jobs:
PR=$(gh pr list --head "$VAULT_BRANCH" --json number -q '.[0].number')
if [ -z "$PR" ]; then
# call the script to create the plugin update PR on Vault
./.github/scripts/plugin-helper-gh-pr-create.sh
gh pr create \
--head "$VAULT_BRANCH" \
--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"
echo "vault_pr_num=$(gh pr list --head "$VAULT_BRANCH" --json number -q '.[0].number')" >> "$GITHUB_OUTPUT"
echo "vault_pr_url=$(gh pr list --head "$VAULT_BRANCH" --json html_url -q '.[0].html_url')" >> "$GITHUB_OUTPUT"
else
echo "Pull request already exists, won't create a new one."
fi
- name: Add labels to Vault CI check PR
if: steps.changes.outputs.count > 0
env:
# this is a different token to the one we have been using that should
# allow us to add labels
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
if [ -z "$vault_pr_num" ]; then
echo "error: no vault PR found"
exit 1
fi
gh pr edit "${{ steps.pr.outputs.vault_pr_num }}" \
--add-label "dependencies,pr/no-changelong,pr/no-milestone" \
--repo hashicorp/vault
- name: Comment on plugin PR
if: steps.changes.outputs.count > 0
env:
GITHUB_TOKEN: ${{secrets.ELEVATED_GITHUB_TOKEN}}
run: |
# get Plugin PR number
plugin_pr_num=$(gh pr list --head "$PLUGIN_BRANCH" --json number --repo "$PLUGIN_REPO" -q '.[0].number')
if [ -z "$plugin_pr_num" ]; then
echo "error: no plugin PR found"
exit 1
fi
if [ -z "${{ steps.pr.outputs.vault_pr_url }}" ]; then
echo "error: no vault PR found"
exit 1
fi
# make a comment on the plugin repo's PR
gh pr comment "$plugin_pr_num" \
--body "Vault CI check PR: ${{ steps.pr.outputs.vault_pr_url }}" \
--repo "$PLUGIN_REPO"

0 comments on commit c121728

Please sign in to comment.