mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 09:42:25 +00:00
VAULT-33693 actions: fix push event PR labels (#29476)
* VAULT-33693: actions: fix push event PR labels Fix pull request label metadata when triggered `push` event types. We now use Github's `associatedPullRequests()` connection on the `Commit` associated with the SHA to resolve the labels. Signed-off-by: Ryan Cragun <me@ryan.ec>
This commit is contained in:
32
.github/actions/metadata/action.yml
vendored
32
.github/actions/metadata/action.yml
vendored
@@ -108,15 +108,33 @@ runs:
|
|||||||
|
|
||||||
labels=$(gh api "/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels" | jq -erc '. | map(.name)')
|
labels=$(gh api "/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels" | jq -erc '. | map(.name)')
|
||||||
else
|
else
|
||||||
|
# We can assume we're being triggered for a 'push' (a merge)
|
||||||
is_draft='false'
|
is_draft='false'
|
||||||
|
|
||||||
# Look up the labels for the pull request that is associated with the last commit. If
|
# Look up the pull request labels for the PR that is associated with
|
||||||
# there are none set it as a JSON encoded empty array.
|
# the commit. If there are none set it as a JSON encoded empty array.
|
||||||
if pr_number=$(gh api "/repos/${{ github.repository }}/commits/${{ github.ref }}/pulls" | jq -erc '.[0].number'); then
|
repo=$(printf ${{ github.repository }} | cut -d "/" -f2)
|
||||||
if ! labels=$(gh api "/repos/${{ github.repository }}/issues/${pr_number}/labels" | jq -erc '. | map(.name)'); then
|
if ! labels=$(gh api graphql -F repo="$repo" -F sha="${{ steps.vault-metadata.outputs.vault-revision }}" -f query='
|
||||||
labels='[]'
|
query($repo: String!, $sha: String!){
|
||||||
fi
|
repository(name: $repo, owner: "hashicorp") {
|
||||||
else
|
commit: object(expression: $sha) {
|
||||||
|
... on Commit {
|
||||||
|
associatedPullRequests(first:1){
|
||||||
|
edges{
|
||||||
|
node{
|
||||||
|
labels(first: 10) {
|
||||||
|
nodes {
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' | jq -erc '.data.repository.commit.associatedPullRequests.edges[0].node.labels.nodes | map(.name)');
|
||||||
|
then
|
||||||
labels='[]'
|
labels='[]'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user