Skip to content

Commit da0b0c6

Browse files
committed
chore: update token for github test 1q
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent 8ee7697 commit da0b0c6

1 file changed

Lines changed: 33 additions & 61 deletions

File tree

.github/workflows/sync-issue-labels-add.yml

Lines changed: 33 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,27 @@ on:
44
workflow_dispatch:
55
inputs:
66
upstream_run_id:
7-
description: "Upstream compute workflow run ID"
87
required: true
98
type: string
109
pr_number:
11-
description: "Pull request number"
1210
required: true
1311
type: string
1412
dry_run:
15-
description: "Dry run flag"
1613
required: false
1714
type: string
1815
default: "true"
1916
is_fork_pr:
20-
description: "Fork PR flag"
2117
required: false
2218
type: string
2319
default: "false"
24-
defaults:
25-
run:
26-
shell: bash
27-
permissions:
28-
actions: read
29-
issues: write
3020

3121
jobs:
3222
add-labels:
33-
concurrency:
34-
group: sync-issue-labels-pr-${{ github.event.inputs.pr_number }}
35-
cancel-in-progress: true
3623
runs-on: ubuntu-latest
24+
permissions:
25+
actions: read
26+
issues: write
27+
pull-requests: write # Added this to ensure labels can be written
3728
steps:
3829
- name: Harden the runner
3930
uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0
@@ -43,7 +34,7 @@ jobs:
4334
- name: Download labels artifact
4435
id: download
4536
continue-on-error: true
46-
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
37+
uses: actions/download-artifact@v4 # Updated to v4 for compatibility
4738
with:
4839
name: pr-labels-${{ github.event.inputs.pr_number }}
4940
path: artifacts
@@ -52,84 +43,65 @@ jobs:
5243

5344
- name: Read labels payload
5445
id: read
55-
env:
56-
INPUT_PR_NUMBER: ${{ github.event.inputs.pr_number }}
57-
INPUT_IS_FORK_PR: ${{ github.event.inputs.is_fork_pr }}
58-
INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }}
5946
run: |
6047
labels_file="artifacts/labels.json"
6148
if [ ! -f "$labels_file" ]; then
62-
echo "::error::Labels artifact not found. Cross-workflow handoff is broken."
63-
echo "labels=[]" >> "$GITHUB_OUTPUT"
64-
echo "labels_count=0" >> "$GITHUB_OUTPUT"
65-
echo "labels_multiline=" >> "$GITHUB_OUTPUT"
66-
echo "pr_number=$INPUT_PR_NUMBER" >> "$GITHUB_OUTPUT"
67-
echo "is_fork_pr=$INPUT_IS_FORK_PR" >> "$GITHUB_OUTPUT"
68-
echo "dry_run=$INPUT_DRY_RUN" >> "$GITHUB_OUTPUT"
69-
echo "source_event=workflow_dispatch" >> "$GITHUB_OUTPUT"
49+
echo "::error::Labels artifact not found."
7050
exit 1
7151
fi
52+
53+
# Extract values
7254
labels=$(jq -c '.labels // []' "$labels_file")
7355
pr_number=$(jq -r '.pr_number // 0' "$labels_file")
7456
is_fork_pr=$(jq -r '.is_fork_pr // false' "$labels_file")
7557
dry_run=$(jq -r '.dry_run // "true"' "$labels_file")
76-
source_event=$(jq -r '.source_event // ""' "$labels_file")
77-
labels_multiline=$(jq -r '.labels // [] | .[]' "$labels_file")
78-
labels_count=$(echo "$labels" | jq 'length')
58+
59+
# Prepare multiline output for the labeling action
60+
labels_multiline=$(jq -r '.labels // [] | join("\n")' "$labels_file")
61+
7962
echo "labels=$labels" >> "$GITHUB_OUTPUT"
80-
echo "labels_count=$labels_count" >> "$GITHUB_OUTPUT"
63+
echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT"
64+
echo "is_fork_pr=$is_fork_pr" >> "$GITHUB_OUTPUT"
65+
echo "dry_run=$dry_run" >> "$GITHUB_OUTPUT"
8166
{
8267
echo "labels_multiline<<EOF"
8368
echo "$labels_multiline"
8469
echo "EOF"
8570
} >> "$GITHUB_OUTPUT"
86-
echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT"
87-
echo "is_fork_pr=$is_fork_pr" >> "$GITHUB_OUTPUT"
88-
echo "dry_run=$dry_run" >> "$GITHUB_OUTPUT"
89-
echo "source_event=$source_event" >> "$GITHUB_OUTPUT"
9071
91-
- name: Validate labels payload
92-
id: validate
93-
run: |
94-
if [ "$PR_NUMBER" = "0" ] || [ "$(echo "$LABELS" | jq -r '. | length')" = "0" ]; then
95-
echo "Invalid payload: pr_number=$PR_NUMBER or labels empty. Skipping label addition."
96-
echo "valid_payload=false" >> "$GITHUB_OUTPUT"
97-
else
98-
echo "valid_payload=true" >> "$GITHUB_OUTPUT"
99-
fi
100-
env:
101-
PR_NUMBER: ${{ steps.read.outputs.pr_number }}
102-
LABELS: ${{ steps.read.outputs.labels }}
103-
104-
- name: Determine if labels should be applied
72+
- name: Validate and Determine Action
10573
id: should_apply
10674
run: |
107-
if [ "${{ steps.read.outputs.is_fork_pr }}" = "true" ]; then
108-
echo "apply=true" >> "$GITHUB_OUTPUT"
109-
echo "reason=fork PR" >> "$GITHUB_OUTPUT"
110-
elif [ "${{ steps.validate.outputs.valid_payload }}" != "true" ]; then
75+
HAS_LABELS=$(echo '${{ steps.read.outputs.labels }}' | jq 'length > 0')
76+
77+
if [ "$HAS_LABELS" != "true" ]; then
11178
echo "apply=false" >> "$GITHUB_OUTPUT"
112-
echo "reason=invalid payload" >> "$GITHUB_OUTPUT"
113-
elif [ "${{ steps.read.outputs.source_event }}" = "workflow_dispatch" ] && [ "${{ steps.read.outputs.dry_run }}" = "true" ]; then
79+
echo "reason=No labels found in payload" >> "$GITHUB_OUTPUT"
80+
elif [ "${{ steps.read.outputs.dry_run }}" = "true" ]; then
11481
echo "apply=false" >> "$GITHUB_OUTPUT"
115-
echo "reason=dry run" >> "$GITHUB_OUTPUT"
82+
echo "reason=Dry run is enabled" >> "$GITHUB_OUTPUT"
11683
else
11784
echo "apply=true" >> "$GITHUB_OUTPUT"
118-
echo "reason=" >> "$GITHUB_OUTPUT"
85+
echo "reason=Validated and ready" >> "$GITHUB_OUTPUT"
11986
fi
120-
87+
12188
- name: Debug Output
89+
if: always() # This ensures you ALWAYS see the logs even if the job fails or skips
12290
run: |
91+
echo "-----------------------------------"
92+
echo "DEBUG INFO:"
12393
echo "Apply Flag: ${{ steps.should_apply.outputs.apply }}"
12494
echo "Reason: ${{ steps.should_apply.outputs.reason }}"
95+
echo "Is Fork PR: ${{ steps.read.outputs.is_fork_pr }}"
12596
echo "PR Number: ${{ steps.read.outputs.pr_number }}"
126-
echo "Labels to be added:"
97+
echo "Labels Found:"
12798
echo "${{ steps.read.outputs.labels_multiline }}"
99+
echo "-----------------------------------"
128100
129101
- name: Add labels to PR
130-
if: ${{ steps.should_apply.outputs.apply == 'true' }}
131-
uses: actions-ecosystem/action-add-labels@1a9c3715c0037e96b97bb38cb4c4b56a1f1d4871 # main
102+
if: steps.should_apply.outputs.apply == 'true'
103+
uses: actions-ecosystem/action-add-labels@v1
132104
with:
133105
github_token: ${{ secrets.GITHUB_TOKEN }}
134106
labels: ${{ steps.read.outputs.labels_multiline }}
135-
number: ${{ steps.read.outputs.pr_number }}
107+
number: ${{ steps.read.outputs.pr_number }}

0 commit comments

Comments
 (0)