Repository navigation
158 lines (143 loc) · 6.01 KB
/
Copy pathupdate.yml
File metadata and controls
158 lines (143 loc) · 6.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Update GitHub Copilot
on:
schedule:
# Run daily at 07:00 UTC
- cron: '0 7 * * *'
workflow_dispatch: # Allow manual trigger
permissions:
contents: write
pull-requests: write
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
env:
DISABLE_FLAKEHUB: "true"
with:
flakehub: false
extra-conf: |
experimental-features = nix-command flakes
accept-flake-config = true
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Run update script
id: update
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod +x scripts/update-version.sh
if ./scripts/update-version.sh 2>&1 | tee update_output.txt; then
echo "update_success=true" >> "$GITHUB_OUTPUT"
if git diff --quiet artifacts/versions.json; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
extract_version() {
local name="$1"
local url
url=$(jq -r ".\"$name\".\"x86_64-linux\".url" artifacts/versions.json 2>/dev/null || echo "")
echo "$url" | grep -oP 'download/v?\K[0-9.]+' || echo "unknown"
}
DESKTOP_VERSION=$(extract_version "GitHub Copilot Desktop")
CLI_VERSION=$(extract_version "GitHub Copilot CLI")
echo "Detected versions — Desktop: $DESKTOP_VERSION, CLI: $CLI_VERSION"
echo "new_version=d${DESKTOP_VERSION}-c${CLI_VERSION}" >> "$GITHUB_OUTPUT"
echo "desktop_version=$DESKTOP_VERSION" >> "$GITHUB_OUTPUT"
echo "cli_version=$CLI_VERSION" >> "$GITHUB_OUTPUT"
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi
else
echo "update_success=false" >> "$GITHUB_OUTPUT"
echo "=== Update script failed ==="
cat update_output.txt
exit 1
fi
- name: Verify packages build
if: steps.update.outputs.has_changes == 'true'
run: |
echo "Running flake check..."
nix flake check
echo "Building updated packages (verifies the new hashes before opening a PR)..."
nix build .#default .#github-copilot-desktop .#github-copilot-cli --no-link --print-build-logs
- name: Create Pull Request
if: steps.update.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: update github copilot (desktop ${{ steps.update.outputs.desktop_version }}, cli ${{ steps.update.outputs.cli_version }})"
title: "chore: update github copilot (desktop ${{ steps.update.outputs.desktop_version }}, cli ${{ steps.update.outputs.cli_version }})"
body: |
## GitHub Copilot Update
This PR updates the GitHub Copilot Nix flake packages.
Detected versions:
- **GitHub Copilot Desktop**: `${{ steps.update.outputs.desktop_version }}`
- **GitHub Copilot CLI**: `${{ steps.update.outputs.cli_version }}`
### Changes
- Updated versions and hashes in `artifacts/versions.json`
### Testing
- ✅ Flake checks passed (`nix flake check`)
- ✅ Built packages successfully
---
🤖 This PR was created automatically by the auto-update workflow.
branch: auto-update/github-copilot-${{ steps.update.outputs.new_version }}
delete-branch: true
labels: |
automated
copilot-update
- name: Enable auto-merge
if: steps.update.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_VERSION: ${{ steps.update.outputs.new_version }}
run: |
MAX_ATTEMPTS=5
ATTEMPT=1
WAIT_TIME=5
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
echo "Attempt $ATTEMPT/$MAX_ATTEMPTS: Looking for PR..."
PR_NUMBER=$(gh pr list --head "auto-update/github-copilot-$NEW_VERSION" --json number --jq '.[0].number')
if [ -n "$PR_NUMBER" ]; then
echo "Found PR #$PR_NUMBER"
echo "Enabling auto-merge..."
if gh pr merge "$PR_NUMBER" --auto --squash; then
echo "✓ Auto-merge enabled for PR #$PR_NUMBER"
exit 0
else
echo "⚠ Failed to enable auto-merge (auto-merge may not be enabled in repository settings), but PR exists"
exit 0
fi
fi
if [ $ATTEMPT -lt $MAX_ATTEMPTS ]; then
echo "PR not found yet, waiting ${WAIT_TIME}s before retry..."
sleep $WAIT_TIME
WAIT_TIME=$((WAIT_TIME * 2))
fi
ATTEMPT=$((ATTEMPT + 1))
done
echo "⚠ Could not find PR after $MAX_ATTEMPTS attempts"
echo "The PR may have been created but not yet visible via API"
- name: Report status
if: always()
env:
UPDATE_SUCCESS: ${{ steps.update.outputs.update_success }}
HAS_CHANGES: ${{ steps.update.outputs.has_changes }}
DESKTOP_VER: ${{ steps.update.outputs.desktop_version }}
CLI_VER: ${{ steps.update.outputs.cli_version }}
run: |
if [[ "$UPDATE_SUCCESS" == "true" ]]; then
if [[ "$HAS_CHANGES" == "true" ]]; then
echo "✅ Update successful! Desktop: $DESKTOP_VER, CLI: $CLI_VER"
else
echo "✅ Already at latest version"
fi
else
echo "❌ Update failed"
exit 1
fi