Skip to content

Commit

Permalink
gh action: fix plugin check workflow (#22084)
Browse files Browse the repository at this point in the history
* gh action: fix plugin check workflow

* use if condition
  • Loading branch information
fairclothjm authored Jul 27, 2023
1 parent 727c73c commit a31c680
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/plugin-update-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
continue-on-error: true
run: |
if [ -z "$vault_pr_num" ]; then
if [ -z "${{ steps.pr.outputs.vault_pr_url }}" ]; then
echo "error: no vault PR found"
exit 1
fi
Expand Down
26 changes: 9 additions & 17 deletions .github/workflows/plugin-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
inputs:
repo:
type: string
description: 'The owner and repository name as per the github.repository context property.'
description: 'The owner and repository name. Ex: hashicorp/vault-plugin-auth-jwt'
required: true
plugin_tag:
type: string
description: 'The name of the plugin tag.'
description: 'The name of the plugin tag. Ex: v0.5.1'
required: true

jobs:
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
run: |
git config user.name hc-github-team-secure-vault-ecosystem
git config user.email hc-github-team-secure-vault-ecosystem@users.noreply.github.com
git add .
git add go.mod go.sum
git commit -m "Automated dependency upgrades"
git push -f origin ${{ github.ref_name }}:"$VAULT_BRANCH"
Expand All @@ -63,8 +63,9 @@ jobs:
if [ -z "$PR" ]; then
gh pr create \
--head "$VAULT_BRANCH" \
--reviewer "${{ github.actor }}" \
--title "Update ${{ inputs.repo }} to ${{ inputs.plugin_tag }}" \
--body "Updates ${{ inputs.repo }} to verify vault CI. Full log: https://github.com/hashicorp/vault/actions/runs/${{ github.run_id }}"
--body "This PR was generated by a GitHub Action. Full log: https://github.com/hashicorp/vault/actions/runs/${{ github.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 url -q '.[0].url')" >> "$GITHUB_OUTPUT"
Expand All @@ -73,13 +74,8 @@ jobs:
fi
- name: Add changelog
continue-on-error: true
if: steps.pr.outputs.vault_pr_num != ''
run: |
if [ -z "$vault_pr_num" ]; then
echo "error: no vault PR found"
exit 1
fi
# strip "hashicorp/" from repo name
PLUGIN=$(echo ${{ inputs.repo }} | awk -F/ '{print $NF}')
echo "plugin: $PLUGIN"
Expand All @@ -94,24 +90,20 @@ jobs:
echo "\`\`\`release-note:change
${PLUGIN_TYPE}/${PLUGIN_SERVICE}: Update plugin to ${{ inputs.plugin_tag }}
\`\`\`" > "changelog/${vault_pr_num}.txt"
\`\`\`" > "changelog/${{ steps.pr.outputs.vault_pr_num }}.txt"
git add .
git add changelog/
git commit -m "Add changelog"
git push origin ${{ github.ref_name }}:"$VAULT_BRANCH"
- name: Add labels to Vault PR
if: steps.pr.outputs.vault_pr_num != ''
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}}
continue-on-error: true
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" \
--repo hashicorp/vault

0 comments on commit a31c680

Please sign in to comment.