Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin automation: use gh cli and add labels #21657

Merged
merged 6 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -50,6 +50,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 @@ -58,9 +59,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"