Skip to content

Commit 1ff3a98

Browse files
committed
Check for updates on a schedule
1 parent bd41dca commit 1ff3a98

2 files changed

Lines changed: 45 additions & 12 deletions

File tree

.github/workflows/update.yaml

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,64 @@ on:
66
version:
77
type: string
88
required: true
9+
schedule:
10+
- cron: "23 * * * *"
911

1012
jobs:
1113
update:
1214
runs-on: ubuntu-latest
1315
env:
14-
VERSION: ${{ inputs.version }}
16+
TAG: ${{ inputs.version }}
1517
GH_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
1618

1719
steps:
20+
- name: Fetch latest tag
21+
if: env.TAG == ''
22+
run: |
23+
tag=$(curl -fsSLI -o /dev/null -w "%{url_effective}" https://github.com/microsoft/vscode/releases/latest)
24+
tag="${tag#https://github.com/microsoft/vscode/releases/tag/}"
25+
echo "TAG=$tag" >> $GITHUB_ENV
26+
27+
- name: Remove leading v from tag
28+
run: |
29+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
30+
1831
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
19-
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
2032
with:
21-
node-version-file: .node-version
33+
submodules: true
34+
35+
- name: Check current version
36+
id: check
37+
run: |
38+
commit="$(git -C lib/vscode rev-parse HEAD)"
39+
if [[ $(git ls-remote --tags https://github.com/microsoft/vscode.git | grep "$commit") == */"$VERSION" ]] ; then
40+
echo done=true >> $GITHUB_OUTPUT
41+
elif git ls-remote --exit-code --heads https://github.com/coder/code-server.git "update/$VERSION" ; then
42+
echo done=true >> $GITHUB_OUTPUT
43+
else
44+
echo done=false >> $GITHUB_OUTPUT
45+
fi
46+
47+
- uses: awalsh128/cache-apt-pkgs-action@2c09a5e66da6c8016428a2172bd76e5e4f14bb17 # latest
48+
if: steps.check.outputs.done == 'false'
49+
with:
50+
packages: quilt
51+
version: 1.0
2252

2353
- run: ./ci/build/update-vscode.sh
54+
if: steps.check.outputs.done == 'false'
2455

2556
- name: Open PR
57+
if: steps.check.outputs.done == 'false'
2658
run: |
2759
git config --global user.name cdrci
2860
git config --global user.email opensource@coder.com
29-
git checkout -b update/${{ env.VERSION }}
61+
git checkout -b "update/$VERSION"
3062
git add .
31-
git commit -m "Update VS Code to ${{ env.VERSION }}"
32-
git push -u origin $(git branch --show)
33-
gh pr create --repo coder/code-server-aur \
34-
--title "Update VS Code to ${{ env.VERSION }}" \
63+
git commit -m "Update VS Code to $VERSION"
64+
git push -u origin "$(git branch --show)"
65+
gh pr create \
66+
--repo coder/code-server \
67+
--title "Update VS Code to $VERSION" \
3568
--body-file .cache/checklist \
3669
--draft

ci/build/update-vscode.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function refresh_patches() {
4242
function update_node() {
4343
local node_version
4444
node_version=$(cat .node-version)
45-
if [[ $node_version == $target_node_version ]] ; then
45+
if [[ $node_version == "$target_node_version" ]] ; then
4646
echo "$node_version already matches $target_node_version"
4747
else
4848
echo "Updating from $node_version to $target_node_version..."
@@ -52,11 +52,11 @@ function update_node() {
5252

5353
function get-webview-script-hash() {
5454
local html
55-
html=$(<$1)
55+
html=$(<"$1")
5656
local start_tag='<script async type="module">'
5757
local end_tag="</script>"
58-
html=${html##*$start_tag}
59-
html=${html%%$end_tag*}
58+
html=${html##*"$start_tag"}
59+
html=${html%%"$end_tag"*}
6060
echo -n "$html" | openssl sha256 -binary | openssl base64
6161
}
6262

0 commit comments

Comments
 (0)