ci(label-actions): actions can't directly access secrets
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
23
.github/actions/add-labels/action.yml
vendored
23
.github/actions/add-labels/action.yml
vendored
@@ -3,7 +3,7 @@ description: adds label(s) to labelable
|
|||||||
inputs:
|
inputs:
|
||||||
gh_token:
|
gh_token:
|
||||||
description: gh api access token to use
|
description: gh api access token to use
|
||||||
default: ${{ secrets.GITHUB_TOKEN }}
|
required: true
|
||||||
repository:
|
repository:
|
||||||
description: the OWNER/REPOSITORY to operate on
|
description: the OWNER/REPOSITORY to operate on
|
||||||
default: ${{ github.repository }}
|
default: ${{ github.repository }}
|
||||||
@@ -116,7 +116,7 @@ runs:
|
|||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ inputs.gh_token }}
|
GH_TOKEN: ${{ inputs.gh_token }}
|
||||||
REPOSITORY: ${{ inputs.repository }}
|
REPOSITORY: ${{ inputs.repository }}
|
||||||
ISSUES: ${{ inputs.labels }}
|
ISSUES: ${{ inputs.issues }}
|
||||||
run: |
|
run: |
|
||||||
owner=$(echo "$REPOSITORY" | cut -d '/' -f 1)
|
owner=$(echo "$REPOSITORY" | cut -d '/' -f 1)
|
||||||
repo=$(echo "$REPOSITORY" | cut -d '/' -f 2)
|
repo=$(echo "$REPOSITORY" | cut -d '/' -f 2)
|
||||||
@@ -164,14 +164,13 @@ runs:
|
|||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ inputs.gh_token }}
|
GH_TOKEN: ${{ inputs.gh_token }}
|
||||||
REPO_ID: ${{ steps.collect_labels.outputs.repo_id }}
|
REPO_ID: ${{ steps.collect_labels.outputs.repo_id }}
|
||||||
LABELS: ${{ steps.collect_labels.outputs.labels }}
|
EXISTING: ${{ steps.collect_labels.outputs.found }}
|
||||||
MISSING: ${{ steps.collect_labels.outputs.missing }}
|
MISSING: ${{ steps.collect_labels.outputs.missing }}
|
||||||
run: |
|
run: |
|
||||||
query=$(
|
query=$(
|
||||||
jq -nr \
|
jq -nr \
|
||||||
--argjson labels "$MISSING" \
|
--argjson labels "$MISSING" \
|
||||||
--arg repo "$REPO_ID" \
|
--arg repo "$REPO_ID" '
|
||||||
'
|
|
||||||
"mutation {\n" + (
|
"mutation {\n" + (
|
||||||
reduce ($labels | keys | .[] | [., $labels[.]]) as $i ([0, ""]; [
|
reduce ($labels | keys | .[] | [., $labels[.]]) as $i ([0, ""]; [
|
||||||
.[0] + 1,
|
.[0] + 1,
|
||||||
@@ -196,15 +195,13 @@ runs:
|
|||||||
'
|
'
|
||||||
)
|
)
|
||||||
data=$(
|
data=$(
|
||||||
gh api graphql -f query="$query" \
|
gh api graphql -f query="$query" | jq --argjson existing "$EXISTING" '
|
||||||
| jq --argjson existing "$LABELS" \
|
reduce .data[].label as $i ({}; .[$i.name] = {"id": $i.id, "color": $i.color })
|
||||||
'
|
| . + $existing
|
||||||
reduce .data[].label as $i ({}; .[$i.name] = {"id": $i.id, "color": $i.color })
|
'
|
||||||
| . + $existing
|
|
||||||
'
|
|
||||||
)
|
)
|
||||||
lable_ids=$(jq -c '[.[].id]' <<< "$data")
|
label_ids=$(jq -c '[.[].id]' <<< "$data")
|
||||||
echo "label_ids=$lable_ids" >> "$GITHUB_OUTPUT"
|
echo "label_ids=$label_ids" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Apply Labels
|
- name: Apply Labels
|
||||||
id: apply_labels
|
id: apply_labels
|
||||||
|
|||||||
6
.github/actions/delete-labels/action.yml
vendored
6
.github/actions/delete-labels/action.yml
vendored
@@ -3,7 +3,7 @@ description: delete Label(s)
|
|||||||
inputs:
|
inputs:
|
||||||
gh_token:
|
gh_token:
|
||||||
description: gh api access token to use
|
description: gh api access token to use
|
||||||
default: ${{ secrets.GITHUB_TOKEN }}
|
required: true
|
||||||
repository:
|
repository:
|
||||||
description: the OWNER/REPOSITORY to operate on
|
description: the OWNER/REPOSITORY to operate on
|
||||||
default: ${{ github.repository }}
|
default: ${{ github.repository }}
|
||||||
@@ -66,10 +66,10 @@ runs:
|
|||||||
| select( objects | .name as $name | any($labels[]; . == $name ) )
|
| select( objects | .name as $name | any($labels[]; . == $name ) )
|
||||||
) as $i ({}; .[$i.name] = {"id": $i.id})
|
) as $i ({}; .[$i.name] = {"id": $i.id})
|
||||||
) as $found
|
) as $found
|
||||||
| [.[].id]
|
| [$found[].id]
|
||||||
'
|
'
|
||||||
)
|
)
|
||||||
echo "label_ids=$data" >>> "$GITHUB_OUTPUT"
|
echo "label_ids=$data" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Delete Labels
|
- name: Delete Labels
|
||||||
id: delete_labels
|
id: delete_labels
|
||||||
|
|||||||
3
.github/workflows/manual-add-label.yml
vendored
3
.github/workflows/manual-add-label.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Manual workflow to apply labels in bulk
|
name: Apply labels in bulk
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -38,6 +38,7 @@ jobs:
|
|||||||
- name: Run Label Action
|
- name: Run Label Action
|
||||||
uses: ./.github/actions/add-labels
|
uses: ./.github/actions/add-labels
|
||||||
with:
|
with:
|
||||||
|
gh_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
issues: ${{ inputs.issues }}
|
issues: ${{ inputs.issues }}
|
||||||
labels: ${{ inputs.labels }}
|
labels: ${{ inputs.labels }}
|
||||||
colors: ${{ inputs.colors }}
|
colors: ${{ inputs.colors }}
|
||||||
|
|||||||
3
.github/workflows/manual-delete-labels.yml
vendored
3
.github/workflows/manual-delete-labels.yml
vendored
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
name: Manual workflow to delete labels in bulk
|
name: Delete labels in bulk
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -26,4 +26,5 @@ jobs:
|
|||||||
- name: Run Label Action
|
- name: Run Label Action
|
||||||
uses: ./.github/actions/delete-labels
|
uses: ./.github/actions/delete-labels
|
||||||
with:
|
with:
|
||||||
|
gh_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
labels: ${{ inputs.labels }}
|
labels: ${{ inputs.labels }}
|
||||||
|
|||||||
Reference in New Issue
Block a user