Skip to content

Commit 5ae4457

Browse files
committed
Add Copilot setup workflow and update .gitignore
- Create a new GitHub Actions workflow for Copilot setup steps. - Add triggers for manual dispatch, push, and pull request events. - Include steps for checking out code and parsing attachments. - Update .gitignore to include GitHub temporary attachments directory.
1 parent 0a03bd0 commit 5ae4457

3 files changed

Lines changed: 103 additions & 5 deletions

File tree

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: "Copilot Setup Steps"
2+
3+
# Automatically run the setup steps when they are changed to allow for easy validation, and
4+
# allow manual testing through the repository's "Actions" tab
5+
on:
6+
workflow_dispatch:
7+
push:
8+
paths:
9+
- .github/workflows/copilot-setup-steps.yml
10+
pull_request:
11+
paths:
12+
- .github/workflows/copilot-setup-steps.yml
13+
14+
jobs:
15+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
16+
copilot-setup-steps:
17+
runs-on: ubuntu-latest
18+
19+
# Set the permissions to the lowest permissions possible needed for your steps.
20+
# Copilot will be given its own token for its operations.
21+
permissions:
22+
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
23+
contents: read
24+
25+
# You can define any steps you want, and they will run before the agent starts.
26+
# If you do not check out your code, Copilot will do this for you.
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v5
30+
31+
- name: Parse COPILOT_AGENT_PROMPT and extract attachments
32+
env:
33+
COPILOT_AGENT_INPUTS: ${{ inputs.COPILOT_AGENT_INPUTS }}
34+
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
35+
run: |
36+
# Use a temp directory in the repo so Copilot agent can access it
37+
ATTACHMENTS_DIR=".github/temp/attachments"
38+
mkdir -p "$ATTACHMENTS_DIR"
39+
rm -rf "$ATTACHMENTS_DIR"/* 2>/dev/null || true
40+
41+
# Extract COPILOT_AGENT_PROMPT from COPILOT_AGENT_INPUTS (it's a nested JSON string)
42+
PROMPT_BASE64=$(echo "$COPILOT_AGENT_INPUTS" | jq -r '.COPILOT_AGENT_PROMPT // empty')
43+
44+
if [ -z "$PROMPT_BASE64" ]; then
45+
echo "COPILOT_AGENT_PROMPT not found in inputs"
46+
exit 0
47+
fi
48+
49+
echo "=== Decoding COPILOT_AGENT_PROMPT ==="
50+
PROMPT_CONTENT=$(echo "$PROMPT_BASE64" | base64 -d)
51+
echo "$PROMPT_CONTENT"
52+
53+
# Extract issue description content between <issue_description> tags
54+
ISSUE_BODY=$(echo "$PROMPT_CONTENT" | sed -n '/<issue_description>/,/<\/issue_description>/p' | sed 's/<[^>]*>//g')
55+
echo "=== Issue Body ==="
56+
echo "$ISSUE_BODY"
57+
58+
# Extract all GitHub user-attachments URLs (covers both /files/ and /assets/ paths)
59+
# URLs end with ) in markdown links or " in HTML attributes
60+
ALL_URLS=$(echo "$PROMPT_CONTENT" | grep -oE 'https://github\.com/user-attachments/[^)"]+' | sort -u || true)
61+
62+
if [ -z "$ALL_URLS" ]; then
63+
echo "No attachment URLs found in COPILOT_AGENT_PROMPT"
64+
exit 0
65+
fi
66+
67+
echo "=== Found Attachment URLs ==="
68+
echo "$ALL_URLS"
69+
70+
# Print extracted filenames
71+
echo "=== Attachment Filenames ==="
72+
echo "$ALL_URLS" | while read -r URL; do
73+
if [ -n "$URL" ]; then
74+
FILENAME=$(basename "$URL" | sed 's/?.*//')
75+
echo "$FILENAME"
76+
fi
77+
done
78+
79+
# Download each attachment
80+
echo "$ALL_URLS" | while read -r URL; do
81+
if [ -n "$URL" ]; then
82+
FILENAME=$(basename "$URL" | sed 's/?.*//')
83+
echo "Downloading: $URL -> $ATTACHMENTS_DIR/$FILENAME"
84+
curl -L -H "Authorization: token ${PERSONAL_ACCESS_TOKEN}" \
85+
"$URL" \
86+
-o "$ATTACHMENTS_DIR/$FILENAME" || echo "Failed to download: $URL"
87+
fi
88+
done
89+
90+
echo "=== Downloaded Files ==="
91+
ls -la "$ATTACHMENTS_DIR"
92+
93+
echo "=== Attachment File Paths ==="
94+
for f in "$ATTACHMENTS_DIR"/*; do
95+
if [ -f "$f" ]; then
96+
echo "$f"
97+
fi
98+
done
99+

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ temp-*
5656
.venv/
5757

5858
.VS/
59+
60+
# GitHub temporary attachments
61+
.github/temp/

requirements.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,4 @@ black>=23.0.0
1010
azure-storage-blob>=12.16.0
1111
azure-core>=1.24.0
1212
selenium>=4.14.0
13-
webdriver-manager>=4.0.1
14-
pandas
15-
numpy
16-
matplotlib
17-
seaborn
13+
webdriver-manager>=4.0.1

0 commit comments

Comments
 (0)