Update Automation #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Automation | |
| on: | |
| # schedule: | |
| # - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| update-automation: | |
| name: Run Automation Tasks | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: true | |
| - name: Get latest semver branch | |
| run: | | |
| git fetch origin | |
| LATEST_SEMVER=$(git branch -r | grep -E 'origin/[0-9]+\.[0-9]+\.[0-9]+$' | sed 's/.*origin\///' | sort -V | tail -1) | |
| if [ -z "$LATEST_SEMVER" ]; then | |
| LATEST_SEMVER="main" | |
| echo "No semver branches found, using main" | |
| fi | |
| echo "LATEST_SEMVER=$LATEST_SEMVER" >> $GITHUB_ENV | |
| echo "Using branch: $LATEST_SEMVER" | |
| git checkout "$LATEST_SEMVER" | |
| git submodule update --init --recursive | |
| - name: Check if update needed | |
| run: | | |
| cd third-party-src | |
| git fetch --tags | |
| CURRENT_TAG=$(git describe --tags --exact-match HEAD 2>/dev/null | head -1) | |
| if [ -z "$CURRENT_TAG" ]; then | |
| echo "Error: Submodule is not on a tagged commit" | |
| exit 1 | |
| fi | |
| cd .. | |
| LATEST_TAG=$(curl -L \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| https://api.github.com/repos/microsoft/vscode/releases/latest | jq -r '.tag_name') | |
| echo "Current tag: $CURRENT_TAG" | |
| echo "Latest tag: $LATEST_TAG" | |
| if [ "$CURRENT_TAG" = "$LATEST_TAG" ]; then | |
| echo "Submodule is up to date with latest VS Code release" | |
| exit 0 | |
| else | |
| echo "Update needed: $CURRENT_TAG -> $LATEST_TAG" | |
| # Create staging branch | |
| STAGING_BRANCH="staging-code-editor-$LATEST_TAG" | |
| echo "Creating staging branch: $STAGING_BRANCH" | |
| git checkout -b "$STAGING_BRANCH" | |
| # Update submodule to latest VS Code release | |
| echo "Updating submodule to $LATEST_TAG" | |
| cd third-party-src | |
| git fetch --tags | |
| git checkout "$LATEST_TAG" | |
| cd .. | |
| # Configure git user and commit changes | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add third-party-src | |
| git commit -m "Update VS Code submodule to $LATEST_TAG" | |
| git push origin "$STAGING_BRANCH" | |
| echo "✅ Created staging branch: $STAGING_BRANCH with VS Code $LATEST_TAG" | |
| fi | |