The update-vscode.yml GitHub Actions workflow automatically checks for new VS Code releases daily and creates pull requests to update the devcontainer when a new version is available.
- Daily Check: The workflow runs every day at 2:00 AM UTC (configurable via cron schedule)
- Version Detection: Queries the GitHub API to get the latest stable VS Code release tag
- Commit Hash Retrieval: Fetches the commit hash associated with the latest release tag
- Comparison: Compares the latest release commit hash with the current
VSCODE_COMMITinDockerfile - Update Process: If a new version is found:
- Updates the
VSCODE_COMMITargument in the Dockerfile - Creates a new branch named
automated/update-vscode-<short-commit-hash> - Opens a pull request with detailed information about the update
- Enables auto-merge to automatically merge the PR once checks pass
- Updates the
For the workflow to function properly, you need to enable the following settings in your GitHub repository:
Go to Settings → Actions → General → Workflow permissions:
- Select "Read and write permissions"
- Check "Allow GitHub Actions to create and approve pull requests"
Go to Settings → General → Pull Requests:
- Check "Allow auto-merge"
To ensure auto-merge works safely, configure branch protection for main:
Go to Settings → Branches → Add rule:
- Branch name pattern:
main - Check "Require status checks to pass before merging"
- Select the required status checks (e.g.,
build-and-publish) - Check "Require branches to be up to date before merging"
With these settings, the PR will only auto-merge after all required checks pass.
You can manually trigger the workflow at any time:
gh workflow run update-vscode.ymlOr via the GitHub UI:
- Go to Actions → Update VS Code Version
- Click Run workflow
- Creates a PR with:
- Title:
chore: update VS Code to <version-tag> - Labels:
automated,dependencies,devcontainer - Detailed description with version information
- Title:
- Triggers the existing build workflow (via PR)
- Auto-merge enabled (merges automatically once checks pass)
- Branch automatically deleted after merge
- Workflow completes successfully
- No PR is created
- Summary indicates no action needed
The workflow performs the following steps:
- Checkout repository: Checks out the repository code
- Get current VS Code commit: Extracts the current
VSCODE_COMMITfrom the Dockerfile - Fetch latest stable VS Code commit:
- Queries GitHub API for the latest release tag
- Fetches the commit hash for that tag
- Validates the commit hash format
- Check if update needed: Compares current vs latest commit hashes
- Update Dockerfile: Updates the
VSCODE_COMMITargument if needed - Create Pull Request: Uses
peter-evans/create-pull-request@v7to create the PR - Enable auto-merge: Uses GitHub CLI to enable auto-merge on the PR
- Summary: Provides a summary in the GitHub Actions UI
Edit the cron expression in .github/workflows/update-vscode.yml:
on:
schedule:
# Run daily at 2 AM UTC
- cron: '0 2 * * *'Examples:
- Twice daily:
'0 2,14 * * *'(2 AM and 2 PM) - Weekly:
'0 2 * * 1'(Monday at 2 AM) - Hourly:
'0 * * * *'
Remove or comment out the "Enable auto-merge" step in the workflow file.
Edit the merge strategy in the "Enable auto-merge" step:
# Current: squash merge
gh pr merge "$PR_NUMBER" --auto --squash --delete-branch
# Alternative: merge commit
gh pr merge "$PR_NUMBER" --auto --merge --delete-branch
# Alternative: rebase
gh pr merge "$PR_NUMBER" --auto --rebase --delete-branch# List recent runs
gh run list --workflow=update-vscode.yml
# View details of latest run
gh run view --workflow=update-vscode.yml
# Watch a running workflow
gh run watch# List PRs created by the workflow
gh pr list --label automated --label dependencies
# View a specific PR
gh pr view <PR_NUMBER>Possible causes:
- Insufficient permissions (check workflow permissions in settings)
- Branch protection rules preventing PR creation
- Network issues accessing GitHub API
Solution:
- Verify "Read and write permissions" are enabled
- Ensure "Allow GitHub Actions to create and approve pull requests" is checked
- Check the workflow logs for specific error messages
Possible causes:
- Auto-merge not enabled in repository settings
- Required status checks not configured
- Status checks failing
- Branch protection rules misconfigured
Solution:
- Enable auto-merge in repository settings
- Configure branch protection rules with required status checks
- Check the PR status checks and fix any failures
- Verify the workflow has sufficient permissions
The workflow uses the GitHub API to fetch VS Code releases. If you hit rate limits:
Solution:
- The workflow uses
GITHUB_TOKENwhich has higher rate limits (1000 requests/hour) - Consider reducing the frequency of scheduled runs
- Check rate limit status:
curl -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/rate_limit
If the workflow fails to fetch a valid commit hash:
Possible causes:
- GitHub API returned unexpected format
- VS Code release structure changed
- Network/connectivity issues
Solution:
- Check the workflow logs for the specific error
- Manually verify the latest release:
curl -s https://api.github.com/repos/microsoft/vscode/releases/latest - The workflow validates commit hashes are 40-character hex strings
The auto-update workflow integrates seamlessly with existing workflows:
- build-devcontainer.yml: Triggered automatically when PR is created
- Security scanning: Runs as part of the build workflow
- Container publishing: Only happens after merge to main
- The workflow only updates a single ARG value in the Dockerfile
- Changes are reviewed via PR before merge (even with auto-merge)
- All updates trigger the full build and test pipeline
- Security scans run automatically on the updated container
- Auto-merge only proceeds if all checks pass
- Uses
GITHUB_TOKENwith minimal required permissions
When an update is available, the workflow creates a PR like this:
## 🔄 Automated VS Code Update
This PR updates the VS Code commit hash to the latest stable release.
**Previous version:** `7d842fb85a0275a4a8e4d7e040d2625abbf7f084`
**New version:** `a1b2c3d4e5f6789012345678901234567890abcd`
**Release tag:** `1.95.0`
### Changes
- Updated `VSCODE_COMMIT` in `Dockerfile`
### Verification
This PR will trigger the build workflow to ensure the container builds successfully with the new VS Code version.If you need to temporarily disable the workflow:
- Via GitHub UI: Go to Actions → Update VS Code Version → "..." → Disable workflow
- Via CLI:
gh workflow disable update-vscode.yml
To re-enable:
gh workflow enable update-vscode.ymlThe workflow relies on:
- GitHub Actions:
actions/checkout@v4 - Create Pull Request:
peter-evans/create-pull-request@v7 - GitHub CLI:
gh(pre-installed on GitHub-hosted runners) - Standard tools:
curl,jq,grep,sed
- v1.0: Initial implementation with daily checks and auto-merge
- Uses
peter-evans/create-pull-request@v7for PR creation - Fetches VS Code releases via GitHub API