mirror of
https://github.com/coder/code-server.git
synced 2026-11-30 00:17:01 +08:00
* ci: open the update and Helm/changelog PRs as coder-automations The org doesn't let GITHUB_TOKEN create pull requests, so publish.yaml's repo job failed to open the v4.146.0 Helm/changelog PR, and update.yaml will fail to open the next "Update Code to X" PR. Both jobs now check out without persisted credentials, run their update script, then mint a coder-automations token (Cloud KMS) for coder/code-server only, and push and open the PR with it. update.yaml runs in the new main-only update environment; the repo job in release. GITHUB_TOKEN drops to contents: read. PRs opened by the App also trigger CI, which GITHUB_TOKEN-created ones didn't. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(publish): no dependency cache in the npm publish job setup-node caches the package manager's store by default, so a cache saved by another run could reach the job that publishes to npm. Turn it off there (zizmor cache-poisoning). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
98 lines
3.4 KiB
YAML
98 lines
3.4 KiB
YAML
name: Update code-server
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
type: string
|
|
required: true
|
|
schedule:
|
|
- cron: "0 16,21 * * *"
|
|
|
|
jobs:
|
|
# The org doesn't let GITHUB_TOKEN open pull requests, so the branch is pushed and the PR opened
|
|
# as the coder-automations App. Its key signs only for this file on main, in the update
|
|
# environment (main only).
|
|
update:
|
|
runs-on: ubuntu-latest
|
|
environment: update
|
|
permissions:
|
|
contents: read
|
|
id-token: write # Cloud KMS signs the coder-automations App's JWT
|
|
env:
|
|
TAG: ${{ inputs.version }}
|
|
|
|
steps:
|
|
- name: Fetch latest tag
|
|
if: env.TAG == ''
|
|
run: |
|
|
tag=$(curl -fsSLI -o /dev/null -w "%{url_effective}" https://github.com/microsoft/vscode/releases/latest)
|
|
tag="${tag#https://github.com/microsoft/vscode/releases/tag/}"
|
|
echo "TAG=$tag" >> $GITHUB_ENV
|
|
|
|
- name: Remove leading v from tag
|
|
run: |
|
|
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
|
|
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
|
|
with:
|
|
submodules: true
|
|
persist-credentials: false
|
|
|
|
- name: Check current version
|
|
id: check
|
|
run: |
|
|
commit="$(git -C lib/vscode rev-parse HEAD)"
|
|
if [[ $(git -C lib/vscode ls-remote --tags | grep "$commit") == */"$VERSION" ]] ; then
|
|
echo "$VERSION update has already been merged into $(git rev-parse --abbrev-ref HEAD)"
|
|
echo done=true >> $GITHUB_OUTPUT
|
|
elif git ls-remote --exit-code --heads origin "update/$VERSION" ; then
|
|
echo "There is already a PR for updating to $VERSION"
|
|
echo done=true >> $GITHUB_OUTPUT
|
|
else
|
|
echo "$VERSION update has not started yet"
|
|
echo done=false >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # latest
|
|
if: steps.check.outputs.done == 'false'
|
|
with:
|
|
packages: quilt
|
|
version: 1.0
|
|
|
|
- run: ./ci/build/update-vscode.sh
|
|
if: steps.check.outputs.done == 'false'
|
|
|
|
# Minted after the update script so the token only exists for the push and the PR.
|
|
- name: Generate coder-automations app token
|
|
id: app_token
|
|
if: steps.check.outputs.done == 'false'
|
|
uses: coder/github-app-token-action@00eaec58ee1bfea9c8b48655b7ab7470b07739e5 # main 2026-11-17
|
|
with:
|
|
client-id: ${{ secrets.CODER_AUTOMATION_APP_ID }}
|
|
kms-key: ${{ secrets.CODER_AUTOMATION_APP_KMS_KEY }}
|
|
workload-identity-provider: ${{ secrets.APP_KEYS_WORKLOAD_ID_PROVIDER }}
|
|
owner: coder
|
|
repositories: code-server
|
|
permissions: |
|
|
contents: write
|
|
pull_requests: write
|
|
|
|
- name: Open PR
|
|
if: steps.check.outputs.done == 'false'
|
|
env:
|
|
GH_TOKEN: ${{ steps.app_token.outputs.token }}
|
|
run: |
|
|
gh auth setup-git
|
|
git config --global user.name cdrci
|
|
git config --global user.email opensource@coder.com
|
|
git checkout -b "update/$VERSION"
|
|
git add .
|
|
git commit -m "Update Code to $VERSION"
|
|
git push -u origin "$(git branch --show)"
|
|
gh pr create \
|
|
--repo coder/code-server \
|
|
--title "Update Code to $VERSION" \
|
|
--body-file .cache/checklist \
|
|
--draft
|