Skip to content

Fix GitHub Actions workflow to create PR in VS Code repo #345

Fix GitHub Actions workflow to create PR in VS Code repo

Fix GitHub Actions workflow to create PR in VS Code repo #345

Workflow file for this run

name: Codicons Build
on:
push:
branches: [ main ]
tags:
- '*' # Only runs on annotated tags
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16'
- name: Install dependencies
run: npm install
- name: Build font
run: npm run build
- name: Upload codicon.ttf as artifact
uses: actions/upload-artifact@v4
with:
name: codicon-font-${{ github.sha }}.ttf
path: dist/codicon.ttf
- name: PR to microsoft/vscode
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH="update-codicons"
MESSAGE="chore: Update codicons to ${{ github.sha }}"
git clone --depth=1 https://github.com/microsoft/vscode.git
cd vscode
git checkout -b $BRANCH
cp -f ../dist/codicon.ttf src/vs/base/browser/ui/codicons/codicon/
cp -f ../dist/codiconsLibrary.ts src/vs/base/common/
git add .
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
if git diff-index --quiet HEAD --; then
echo "No changes to commit"
exit 0
fi
git commit -m "$MESSAGE"
git push -f https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/microsoft/vscode.git $BRANCH
echo "${{ secrets.GITHUB_TOKEN }}" > token.txt
gh auth login --with-token < token.txt
gh pr create \
--title "$MESSAGE" \
--body "" \
--base "main" \
--head "$BRANCH"