Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9d799ea

Browse files
johnstcnaslilac
authored andcommitted
ci(.github/workflows/traiage.yaml): set default inputs on trigger by label assignment (#20100)
When not triggering via `workflow_dispatch`, it looks like the defaultvalues are simply empty.This PR creates an intermediate step to conditionally set defaults basedon `github.event_name`.I'm also adding a commented-out step for installing `gh` that's requiredfor local testing via `nektos/act`. It's not required in a 'real'runner.
1 parent359e00c commit9d799ea

File tree

1 file changed

+58
-35
lines changed

1 file changed

+58
-35
lines changed

‎.github/workflows/traiage.yaml‎

Lines changed: 58 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,57 @@ jobs:
4040
env:
4141
CODER_URL:${{ secrets.TRAIAGE_CODER_URL }}
4242
CODER_SESSION_TOKEN:${{ secrets.TRAIAGE_CODER_SESSION_TOKEN }}
43-
TEMPLATE_NAME:${{ inputs.template_name }}
4443
permissions:
4544
contents:read
4645
issues:write
4746
actions:write
4847

4948
steps:
50-
-name:Get GitHub user ID
51-
id:github-user-id
49+
# This is only required for testing locally using nektos/act, so leaving commented out.
50+
# An alternative is to use a larger or custom image.
51+
# - name: Install Github CLI
52+
# id: install-gh
53+
# run: |
54+
# (type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
55+
# && sudo mkdir -p -m 755 /etc/apt/keyrings \
56+
# && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
57+
# && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
58+
# && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
59+
# && sudo mkdir -p -m 755 /etc/apt/sources.list.d \
60+
# && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
61+
# && sudo apt update \
62+
# && sudo apt install gh -y
63+
64+
-name:Determine Inputs
65+
id:determine-inputs
5266
if:always()
5367
env:
5468
GITHUB_ACTOR:${{ github.actor }}
69+
GITHUB_EVENT_ISSUE_HTML_URL:${{ github.event.issue.html_url }}
5570
GITHUB_EVENT_NAME:${{ github.event_name }}
5671
GITHUB_EVENT_USER_ID:${{ github.event.sender.id }}
5772
GITHUB_EVENT_USER_LOGIN:${{ github.event.sender.login }}
73+
INPUTS_CLEANUP:${{ inputs.cleanup || false }}
74+
INPUTS_ISSUE_URL:${{ inputs.issue_url }}
75+
INPUTS_TEMPLATE_NAME:${{ inputs.template_name || 'traiage' }}
76+
INPUTS_TEMPLATE_PRESET:${{ inputs.template_preset || 'Default'}}
77+
INPUTS_PREFIX:${{ inputs.prefix || 'traiage' }}
5878
GH_TOKEN:${{ github.token }}
5979
run:|
80+
echo "Using template name: ${INPUTS_TEMPLATE_NAME}"
81+
echo "template_name=${INPUTS_TEMPLATE_NAME}" >> "${GITHUB_OUTPUT}"
82+
83+
echo "Using template preset: ${INPUTS_TEMPLATE_PRESET}"
84+
echo "template_preset=${INPUTS_TEMPLATE_PRESET}" >> "${GITHUB_OUTPUT}"
85+
86+
echo "Using prefix: ${INPUTS_PREFIX}"
87+
echo "prefix=${INPUTS_PREFIX}" >> "${GITHUB_OUTPUT}"
88+
89+
echo "Using cleanup: ${INPUTS_CLEANUP}"
90+
echo "cleanup=${INPUTS_CLEANUP}" >> "${GITHUB_OUTPUT}"
91+
6092
# For workflow_dispatch, use the actor who triggered it
61-
# For issues events, use the issue author
93+
# For issues events, use the issue author.
6294
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
6395
if ! GITHUB_USER_ID=$(gh api "users/${GITHUB_ACTOR}" --jq '.id'); then
6496
echo "::error::Failed to get GitHub user ID for actor ${GITHUB_ACTOR}"
@@ -67,12 +99,20 @@ jobs:
6799
echo "Using workflow_dispatch actor: ${GITHUB_ACTOR} (ID: ${GITHUB_USER_ID})"
68100
echo "github_user_id=${GITHUB_USER_ID}" >> "${GITHUB_OUTPUT}"
69101
echo "github_username=${GITHUB_ACTOR}" >> "${GITHUB_OUTPUT}"
102+
103+
echo "Using issue URL: ${INPUTS_ISSUE_URL}"
104+
echo "issue_url=${INPUTS_ISSUE_URL}" >> "${GITHUB_OUTPUT}"
105+
70106
exit 0
71107
elif [[ "${GITHUB_EVENT_NAME}" == "issues" ]]; then
72108
GITHUB_USER_ID=${GITHUB_EVENT_USER_ID}
73109
echo "Using issue author: ${GITHUB_EVENT_USER_LOGIN} (ID: ${GITHUB_USER_ID})"
74110
echo "github_user_id=${GITHUB_USER_ID}" >> "${GITHUB_OUTPUT}"
75111
echo "github_username=${GITHUB_EVENT_USER_LOGIN}" >> "${GITHUB_OUTPUT}"
112+
113+
echo "Using issue URL: ${GITHUB_EVENT_ISSUE_HTML_URL}"
114+
echo "issue_url=${GITHUB_EVENT_ISSUE_HTML_URL}" >> "${GITHUB_OUTPUT}"
115+
76116
exit 0
77117
else
78118
echo "::error::Unsupported event type: ${GITHUB_EVENT_NAME}"
@@ -83,8 +123,8 @@ jobs:
83123
env:
84124
GITHUB_ORG:${{ github.repository_owner }}
85125
GH_TOKEN:${{ github.token }}
86-
GITHUB_USERNAME:${{ steps.github-user-id.outputs.github_username }}
87-
GITHUB_USER_ID:${{ steps.github-user-id.outputs.github_user_id }}
126+
GITHUB_USERNAME:${{ steps.determine-inputs.outputs.github_username }}
127+
GITHUB_USER_ID:${{ steps.determine-inputs.outputs.github_user_id }}
88128
run:|
89129
# Check if the actor is a member of the organization
90130
if ! gh api "orgs/${GITHUB_ORG}/members/${GITHUB_USERNAME}" --silent 2>/dev/null; then
@@ -94,28 +134,10 @@ jobs:
94134
fi
95135
echo "::notice::User ${GITHUB_USERNAME} verified as member of ${GITHUB_ORG} organization"
96136
97-
-name:Determine issue URL
98-
id:determine-issue-url
99-
env:
100-
INPUTS_ISSUE_URL:${{ inputs.issue_url }}
101-
GITHUB_EVENT_ISSUE_HTML_URL:${{ github.event.issue.html_url }}
102-
GITHUB_EVENT_NAME:${{ github.event_name }}
103-
run:|
104-
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
105-
echo "issue_url=${INPUTS_ISSUE_URL}" >> "${GITHUB_OUTPUT}"
106-
exit 0
107-
elif [[ "${GITHUB_EVENT_NAME}" == "issues" ]]; then
108-
echo "issue_url=${GITHUB_EVENT_ISSUE_HTML_URL}" >> "${GITHUB_OUTPUT}"
109-
exit 0
110-
else
111-
echo "::error::Unsupported event type: ${GITHUB_EVENT_NAME}"
112-
exit 1
113-
fi
114-
115137
-name:Extract context key from issue
116138
id:extract-context
117139
env:
118-
ISSUE_URL:${{ steps.determine-issue-url.outputs.issue_url }}
140+
ISSUE_URL:${{ steps.determine-inputs.outputs.issue_url }}
119141
GH_TOKEN:${{ github.token }}
120142
run:|
121143
issue_number="$(gh issue view "${ISSUE_URL}" --json number --jq '.number')"
@@ -146,7 +168,7 @@ jobs:
146168
env:
147169
CODER_SESSION_TOKEN:${{ secrets.TRAIAGE_CODER_SESSION_TOKEN }}
148170
GH_TOKEN:${{ github.token }}
149-
GITHUB_USER_ID:${{ steps.github-user-id.outputs.github_user_id }}
171+
GITHUB_USER_ID:${{ steps.determine-inputs.outputs.github_user_id }}
150172
run:|
151173
user_json=$(
152174
coder users list --github-user-id="${GITHUB_USER_ID}" --output=json
@@ -169,11 +191,12 @@ jobs:
169191
CONTEXT_KEY:${{ steps.extract-context.outputs.context_key }}
170192
GH_TOKEN:${{ github.token }}
171193
GITHUB_REPOSITORY:${{ github.repository }}
172-
ISSUE_URL:${{ steps.determine-issue-url.outputs.issue_url }}
173-
PREFIX:${{ inputs.prefix }}
194+
ISSUE_URL:${{ steps.determine-inputs.outputs.issue_url }}
195+
PREFIX:${{steps.determine-inputs.outputs.prefix }}
174196
RUN_ID:${{ github.run_id }}
197+
TEMPLATE_NAME:${{ steps.determine-inputs.outputs.template_name }}
175198
TEMPLATE_PARAMETERS:${{ secrets.TRAIAGE_TEMPLATE_PARAMETERS }}
176-
TEMPLATE_PRESET:${{ inputs.template_preset }}
199+
TEMPLATE_PRESET:${{steps.determine-inputs.outputs.template_preset }}
177200
run:|
178201
# Fetch issue description using `gh` CLI
179202
issue_description=$(gh issue view "${ISSUE_URL}")
@@ -203,29 +226,29 @@ jobs:
203226
204227
-name:Create and upload archive
205228
id:create-archive
206-
if:inputs.cleanup
229+
if:steps.determine-inputs.outputs.cleanup == 'true'
207230
env:
208231
BUCKET_PREFIX:"gs://coder-traiage-outputs/traiage"
209232
CODER_USERNAME:${{ steps.get-coder-username.outputs.coder_username }}
210233
TASK_NAME:${{ steps.create-task.outputs.TASK_NAME }}
211234
run:|
212235
echo "Waiting for task to complete..."
213-
coder exp task status "${CODER_USERNAME}/$TASK_NAME" --watch
214-
echo "Creating archive for workspace: $TASK_NAME"
236+
coder exp task status "${TASK_NAME}" --watch
237+
echo "Creating archive for workspace: ${TASK_NAME}"
215238
./scripts/traiage.sh archive
216239
echo "archive_url=${BUCKET_PREFIX%%/}/$TASK_NAME.tar.gz" >> "${GITHUB_OUTPUT}"
217240
218241
-name:Generate a summary of the changes and post a comment on GitHub.
219242
id:generate-summary
220-
if:inputs.cleanup
243+
if:steps.determine-inputs.outputs.cleanup == 'true'
221244
env:
222245
ARCHIVE_URL:${{ steps.create-archive.outputs.archive_url }}
223246
BUCKET_PREFIX:"gs://coder-traiage-outputs/traiage"
224247
CODER_USERNAME:${{ steps.get-coder-username.outputs.coder_username }}
225248
CONTEXT_KEY:${{ steps.extract-context.outputs.context_key }}
226249
GH_TOKEN:${{ github.token }}
227250
GITHUB_REPOSITORY:${{ github.repository }}
228-
ISSUE_URL:${{ steps.determine-issue-url.outputs.issue_url }}
251+
ISSUE_URL:${{ steps.determine-inputs.outputs.issue_url }}
229252
TASK_NAME:${{ steps.create-task.outputs.TASK_NAME }}
230253
run:|
231254
SUMMARY_FILE=$(mktemp)
@@ -256,7 +279,7 @@ jobs:
256279
cat "${SUMMARY_FILE}" >> "${GITHUB_STEP_SUMMARY}"
257280
258281
-name:Cleanup task
259-
if:inputs.cleanup && steps.create-task.outputs.TASK_NAME != '' && steps.create-archive.outputs.archive_url != ''
282+
if:steps.determine-inputs.outputs.cleanup == 'true' && steps.create-task.outputs.TASK_NAME != '' && steps.create-archive.outputs.archive_url != ''
260283
run:|
261284
echo "Cleaning up task: $TASK_NAME"
262285
./scripts/traiage.sh delete ||true

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp