Skip to content

Commit da3f378

Browse files
committed
ci(label-actions): actions can't directly access secrets
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
1 parent 7cbdb80 commit da3f378

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

.github/actions/add-labels/action.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: adds label(s) to labelable
33
inputs:
44
gh_token:
55
description: gh api access token to use
6-
default: ${{ secrets.GITHUB_TOKEN }}
6+
required: true
77
repository:
88
description: the OWNER/REPOSITORY to operate on
99
default: ${{ github.repository }}
@@ -116,7 +116,7 @@ runs:
116116
env:
117117
GH_TOKEN: ${{ inputs.gh_token }}
118118
REPOSITORY: ${{ inputs.repository }}
119-
ISSUES: ${{ inputs.labels }}
119+
ISSUES: ${{ inputs.issues }}
120120
run: |
121121
owner=$(echo "$REPOSITORY" | cut -d '/' -f 1)
122122
repo=$(echo "$REPOSITORY" | cut -d '/' -f 2)
@@ -164,14 +164,13 @@ runs:
164164
env:
165165
GH_TOKEN: ${{ inputs.gh_token }}
166166
REPO_ID: ${{ steps.collect_labels.outputs.repo_id }}
167-
LABELS: ${{ steps.collect_labels.outputs.labels }}
167+
EXISTING: ${{ steps.collect_labels.outputs.found }}
168168
MISSING: ${{ steps.collect_labels.outputs.missing }}
169169
run: |
170170
query=$(
171171
jq -nr \
172172
--argjson labels "$MISSING" \
173-
--arg repo "$REPO_ID" \
174-
'
173+
--arg repo "$REPO_ID" '
175174
"mutation {\n" + (
176175
reduce ($labels | keys | .[] | [., $labels[.]]) as $i ([0, ""]; [
177176
.[0] + 1,
@@ -196,15 +195,13 @@ runs:
196195
'
197196
)
198197
data=$(
199-
gh api graphql -f query="$query" \
200-
| jq --argjson existing "$LABELS" \
201-
'
202-
reduce .data[].label as $i ({}; .[$i.name] = {"id": $i.id, "color": $i.color })
203-
| . + $existing
204-
'
198+
gh api graphql -f query="$query" | jq --argjson existing "$EXISTING" '
199+
reduce .data[].label as $i ({}; .[$i.name] = {"id": $i.id, "color": $i.color })
200+
| . + $existing
201+
'
205202
)
206-
lable_ids=$(jq -c '[.[].id]' <<< "$data")
207-
echo "label_ids=$lable_ids" >> "$GITHUB_OUTPUT"
203+
label_ids=$(jq -c '[.[].id]' <<< "$data")
204+
echo "label_ids=$label_ids" >> "$GITHUB_OUTPUT"
208205
209206
- name: Apply Labels
210207
id: apply_labels

.github/actions/delete-labels/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: delete Label(s)
33
inputs:
44
gh_token:
55
description: gh api access token to use
6-
default: ${{ secrets.GITHUB_TOKEN }}
6+
required: true
77
repository:
88
description: the OWNER/REPOSITORY to operate on
99
default: ${{ github.repository }}
@@ -66,10 +66,10 @@ runs:
6666
| select( objects | .name as $name | any($labels[]; . == $name ) )
6767
) as $i ({}; .[$i.name] = {"id": $i.id})
6868
) as $found
69-
| [.[].id]
69+
| [$found[].id]
7070
'
7171
)
72-
echo "label_ids=$data" >>> "$GITHUB_OUTPUT"
72+
echo "label_ids=$data" >> "$GITHUB_OUTPUT"
7373
7474
- name: Delete Labels
7575
id: delete_labels

.github/workflows/manual-add-label.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Manual workflow to apply labels in bulk
1+
name: Apply labels in bulk
22

33
on:
44
workflow_dispatch:
@@ -38,6 +38,7 @@ jobs:
3838
- name: Run Label Action
3939
uses: ./.github/actions/add-labels
4040
with:
41+
gh_token: ${{ secrets.GITHUB_TOKEN }}
4142
issues: ${{ inputs.issues }}
4243
labels: ${{ inputs.labels }}
4344
colors: ${{ inputs.colors }}

.github/workflows/manual-delete-labels.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
name: Manual workflow to delete labels in bulk
2+
name: Delete labels in bulk
33

44
on:
55
workflow_dispatch:
@@ -26,4 +26,5 @@ jobs:
2626
- name: Run Label Action
2727
uses: ./.github/actions/delete-labels
2828
with:
29+
gh_token: ${{ secrets.GITHUB_TOKEN }}
2930
labels: ${{ inputs.labels }}

0 commit comments

Comments
 (0)