CI/CD Pipeline #52
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: CI/CD Pipeline | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| reason: | |
| description: Why are you running this? | |
| required: false | |
| default: Manual trigger | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build the extension | |
| run: npm run compile | |
| - name: Package the extension | |
| run: npm run package | |
| - name: Upload VSIX artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vscode-extension | |
| path: "*.vsix" | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: ${{ github.event_name == 'push' }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download VSIX artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: vscode-extension | |
| path: . | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Deploy to Marketplace | |
| run: | | |
| echo "Deploying to the marketplace..." | |
| # Publish pre-built VSIX using the @vscode/vsce package | |
| FILE=$(ls -1 *.vsix | head -n 1) | |
| echo "Publishing $FILE" | |
| if [ -z "${VSCE_PAT}" ]; then | |
| echo "VSCE_PAT secret is not set" >&2 | |
| exit 1 | |
| fi | |
| npx @vscode/vsce publish --pat "${VSCE_PAT}" --packagePath "$FILE" | |
| env: | |
| VSCE_PAT: ${{ secrets.VSCE_PAT }} |