浏览代码

build: correctly build pr to generate assets (#2051)

Baptiste Augrain 7 月之前
父节点
当前提交
fc453f25f8

+ 31 - 3
.github/workflows/insider-linux.yml

@@ -49,9 +49,12 @@ jobs:
         with:
           ref: ${{ env.GITHUB_BRANCH }}
 
-      - name: Clone VSCode repo
+      - name: Switch to relevant branch
         env:
           PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
+
+      - name: Clone VSCode repo
         run: ./get_repo.sh
 
       - name: Check PR or cron
@@ -84,6 +87,11 @@ jobs:
           ref: ${{ env.GITHUB_BRANCH }}
         if: env.SHOULD_BUILD == 'yes'
 
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
+
       - name: Setup Node.js environment
         uses: actions/setup-node@v4
         with:
@@ -105,8 +113,6 @@ jobs:
         if: env.SHOULD_BUILD == 'yes'
 
       - name: Clone VSCode repo
-        env:
-          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
         run: ./get_repo.sh
         if: env.SHOULD_BUILD == 'yes'
 
@@ -175,6 +181,11 @@ jobs:
           ref: ${{ env.GITHUB_BRANCH }}
         if: env.SHOULD_BUILD == 'yes'
 
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
+
       - name: Install GH
         run: ./install_gh.sh
         if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
@@ -268,6 +279,11 @@ jobs:
         with:
           ref: ${{ env.GITHUB_BRANCH }}
 
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
+
       - name: Setup Node.js environment
         uses: actions/setup-node@v4
         with:
@@ -348,6 +364,11 @@ jobs:
         with:
           ref: ${{ env.GITHUB_BRANCH }}
 
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
+
       - name: Install GH
         run: ./install_gh.sh
         if: env.SHOULD_DEPLOY == 'yes'
@@ -436,6 +457,13 @@ jobs:
 
     steps:
       - uses: actions/checkout@v3
+        with:
+          ref: ${{ env.GITHUB_BRANCH }}
+
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
 
       - uses: docker/setup-qemu-action@v3
 

+ 5 - 2
.github/workflows/insider-macos.yml

@@ -51,6 +51,11 @@ jobs:
         with:
           ref: ${{ env.GITHUB_BRANCH }}
 
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
+
       - name: Setup Node.js environment
         uses: actions/setup-node@v4
         with:
@@ -63,8 +68,6 @@ jobs:
         if: env.VSCODE_ARCH == 'x64'
 
       - name: Clone VSCode repo
-        env:
-          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
         run: . get_repo.sh
 
       - name: Check PR or cron

+ 5 - 2
.github/workflows/insider-windows.yml

@@ -55,6 +55,11 @@ jobs:
         with:
           ref: ${{ env.GITHUB_BRANCH }}
 
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
+
       - name: Setup Node.js environment
         uses: actions/setup-node@v4
         with:
@@ -69,8 +74,6 @@ jobs:
           python-version: '3.11'
 
       - name: Clone VSCode repo
-        env:
-          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
         run: ./get_repo.sh
 
       - name: Check PR or cron

+ 31 - 3
.github/workflows/stable-linux.yml

@@ -48,9 +48,12 @@ jobs:
         with:
           ref: ${{ env.GITHUB_BRANCH }}
 
-      - name: Clone VSCode repo
+      - name: Switch to relevant branch
         env:
           PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
+
+      - name: Clone VSCode repo
         run: ./get_repo.sh
 
       - name: Check PR or cron
@@ -83,6 +86,11 @@ jobs:
           ref: ${{ env.GITHUB_BRANCH }}
         if: env.SHOULD_BUILD == 'yes'
 
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
+
       - name: Setup Node.js environment
         uses: actions/setup-node@v4
         with:
@@ -104,8 +112,6 @@ jobs:
         if: env.SHOULD_BUILD == 'yes'
 
       - name: Clone VSCode repo
-        env:
-          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
         run: ./get_repo.sh
         if: env.SHOULD_BUILD == 'yes'
 
@@ -174,6 +180,11 @@ jobs:
           ref: ${{ env.GITHUB_BRANCH }}
         if: env.SHOULD_BUILD == 'yes'
 
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
+
       - name: Install GH
         run: ./install_gh.sh
         if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
@@ -267,6 +278,11 @@ jobs:
         with:
           ref: ${{ env.GITHUB_BRANCH }}
 
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
+
       - name: Setup Node.js environment
         uses: actions/setup-node@v4
         with:
@@ -347,6 +363,11 @@ jobs:
         with:
           ref: ${{ env.GITHUB_BRANCH }}
 
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
+
       - name: Install GH
         run: ./install_gh.sh
         if: env.SHOULD_DEPLOY == 'yes'
@@ -432,6 +453,13 @@ jobs:
 
     steps:
       - uses: actions/checkout@v3
+        with:
+          ref: ${{ env.GITHUB_BRANCH }}
+
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
 
       - name: Check version
         env:

+ 7 - 2
.github/workflows/stable-macos.yml

@@ -47,6 +47,13 @@ jobs:
 
     steps:
       - uses: actions/checkout@v4
+        with:
+          ref: ${{ env.GITHUB_BRANCH }}
+
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
 
       - name: Setup Node.js environment
         uses: actions/setup-node@v4
@@ -60,8 +67,6 @@ jobs:
         if: env.VSCODE_ARCH == 'x64'
 
       - name: Clone VSCode repo
-        env:
-          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
         run: . get_repo.sh
 
       - name: Check PR or cron

+ 9 - 3
.github/workflows/stable-windows.yml

@@ -52,6 +52,13 @@ jobs:
 
     steps:
       - uses: actions/checkout@v4
+        with:
+          ref: ${{ env.GITHUB_BRANCH }}
+
+      - name: Switch to relevant branch
+        env:
+          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
+        run: ./get_pr.sh
 
       - name: Setup Node.js environment
         uses: actions/setup-node@v4
@@ -67,8 +74,6 @@ jobs:
           python-version: '3.11'
 
       - name: Clone VSCode repo
-        env:
-          PULL_REQUEST_ID: ${{ github.event.inputs.checkout_pr }}
         run: ./get_repo.sh
 
       - name: Check PR or cron
@@ -85,7 +90,6 @@ jobs:
       - name: Build
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-          GITHUB_USERNAME: ${{ github.repository_owner }}
           npm_config_arch: ${{ matrix.vscode_arch }}
           npm_config_target_arch: ${{ matrix.vscode_arch }}
         run: ./build.sh
@@ -129,6 +133,8 @@ jobs:
 
     steps:
       - uses: actions/checkout@v4
+        with:
+          ref: ${{ env.GITHUB_BRANCH }}
 
       - name: Check version
         run: ./stores/winget/check_version.sh

+ 14 - 0
get_pr.sh

@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+set -e
+
+if [[ -n "${PULL_REQUEST_ID}" ]]; then
+  BRANCH_NAME=$( git rev-parse --abbrev-ref HEAD )
+
+  git config --global user.email "$( echo "${GITHUB_USERNAME}" | awk '{print tolower($0)}' )-ci@not-real.com"
+  git config --global user.name "${GITHUB_USERNAME} CI"
+  git fetch --unshallow
+  git fetch origin "pull/${PULL_REQUEST_ID}/head"
+  git checkout FETCH_HEAD
+  git merge --no-edit "origin/${BRANCH_NAME}"
+fi

+ 0 - 11
get_repo.sh

@@ -8,17 +8,6 @@ if [[ "${CI_BUILD}" != "no" ]]; then
   git config --global --add safe.directory "/__w/$( echo "${GITHUB_REPOSITORY}" | awk '{print tolower($0)}' )"
 fi
 
-if [[ -n "${PULL_REQUEST_ID}" ]]; then
-  BRANCH_NAME=$( git rev-parse --abbrev-ref HEAD )
-
-  git config --global user.email "$( echo "${GITHUB_USERNAME}" | awk '{print tolower($0)}' )-ci@not-real.com"
-  git config --global user.name "${GITHUB_USERNAME} CI"
-  git fetch --unshallow
-  git fetch origin "pull/${PULL_REQUEST_ID}/head"
-  git checkout FETCH_HEAD
-  git merge --no-edit "origin/${BRANCH_NAME}"
-fi
-
 if [[ -z "${RELEASE_VERSION}" ]]; then
   if [[ "${VSCODE_LATEST}" == "yes" ]] || [[ ! -f "${VSCODE_QUALITY}.json" ]]; then
     echo "Retrieve lastest version"