From 506db7b9bf590328db47b0ba10bb8dbf72760b89 Mon Sep 17 00:00:00 2001 From: John-Michael Faircloth Date: Thu, 6 Jul 2023 16:18:52 -0500 Subject: [PATCH] workflows: update plugin check job to use branch as ref (#21638) * workflows: update plugin check job to use branch as ref * make actionlint happy --- .github/scripts/plugin-helper-gh-pr-create.sh | 4 ++-- .github/workflows/plugin-update-check.yml | 21 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/scripts/plugin-helper-gh-pr-create.sh b/.github/scripts/plugin-helper-gh-pr-create.sh index a5540bc3332b..5c78a60b379f 100755 --- a/.github/scripts/plugin-helper-gh-pr-create.sh +++ b/.github/scripts/plugin-helper-gh-pr-create.sh @@ -34,8 +34,8 @@ 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') +vault_pr_num=$(echo "$resp" | jq -r '.number') +vault_pr_url=$(echo "$resp" | jq -r '.html_url') echo "Vault PR number: $vault_pr_url" # add labels to Vault PR - this requires a wider permission set than we currently have available as a repo token diff --git a/.github/workflows/plugin-update-check.yml b/.github/workflows/plugin-update-check.yml index 99c23350617e..96588a9e377b 100644 --- a/.github/workflows/plugin-update-check.yml +++ b/.github/workflows/plugin-update-check.yml @@ -5,10 +5,6 @@ on: type: string description: 'The owner and repository name as per the github.repository context property.' required: true - sha: - type: string - description: 'The hash of the plugin repository commit to use' - required: true plugin_branch: type: string description: 'The name of the plugin branch' @@ -18,29 +14,32 @@ jobs: plugin-update-check: runs-on: ubuntu-latest env: - COMMIT_SHA: "${{inputs.sha}}" PLUGIN_REPO: "${{inputs.repo}}" PLUGIN_BRANCH: "${{inputs.plugin_branch}}" - VAULT_BRANCH: "auto-plugin-update/${{inputs.repo}}/${{inputs.sha}}" + VAULT_BRANCH: "auto-plugin-update/${{inputs.repo}}/${{inputs.plugin_branch}}" RUN_ID: "${{github.run_id}}" steps: - - run: echo "would use $COMMIT_SHA of $PLUGIN_REPO" - # checkout + - run: echo "Branch $PLUGIN_BRANCH of $PLUGIN_REPO" - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: # We don't use the default token so that checks are executed on the resulting PR # https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow token: ${{ secrets.ELEVATED_GITHUB_TOKEN }} - # activate go + - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 + with: + go-version-file: .go-version + - name: update plugin run: | - go get "github.com/$PLUGIN_REPO@$COMMIT_SHA" + go get "github.com/$PLUGIN_REPO@$PLUGIN_BRANCH" go mod tidy + - name: detect changes id: changes run: | echo "count=$(git status --porcelain=v1 2>/dev/null | wc -l)" >> "$GITHUB_OUTPUT" + - name: commit/push if: steps.changes.outputs.count > 0 run: | @@ -49,6 +48,7 @@ jobs: git add . git commit -m "Automated dependency upgrades" git push -f origin ${{ github.ref_name }}:"$VAULT_BRANCH" + - name: Open pull request if needed if: steps.changes.outputs.count > 0 env: @@ -63,5 +63,4 @@ jobs: else echo "Pull request already exists, won't create a new one." - exit 1 fi