Welcome to mirror list, hosted at ThFree Co, Russian Federation.

create-cli-deps-pr.yml « workflows « .github - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a59302ebeb0acdce5b8131fc269fb7dfe6ec5505 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: "Create CLI Deps PR"

on:
  workflow_dispatch:
    inputs:
      npmVersion:
        description: "6.x.x or latest"
        required: true
        default: 'latest'


jobs:
  create-pull-request:
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.NPM_ROBOT_USER_PAT }}
      NPM_VERSION: ${{ github.event.inputs.npmVersion }}
      SUPPORT_BRANCH: "v14.x-staging"
    steps:
      - name: Update gh cli & install jq parser
        run: |
          sudo apt-get update -y
          sudo apt update
          sudo apt-get install -y jq
          sudo apt install gh
      - name: Checkout npm/node
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
          ref: master
          repository: "npm/node"
          token: ${{ secrets.NPM_ROBOT_USER_PAT }}
      - name: Pull (Fast-Forward) upstream
        id: sync
        uses: aormsby/Fork-Sync-With-Upstream-action@v2.1
        with:
          upstream_repository: nodejs/node
          upstream_branch: master
          target_branch: master
          git_pull_args: --ff-only                    # optional arg use, defaults to simple 'pull'
          github_token: ${{ secrets.NPM_ROBOT_USER_PAT }}   # optional, for accessing repos that require authentication
      - name: Run dependency updates and create PR
        run: |
          npm_tag=""
          base_branch=""
          if [ "$NPM_VERSION" == "latest" ]
          then 
            npm_tag=`npm view npm@latest version`
            base_branch="master"
          else
            npm_tag="$NPM_VERSION"
            base_branch="v14.x-staging"
          fi 

          git config user.name "npm team"
          git config user.email "ops+robot@npmjs.com"
          git checkout -b "npm-$npm_tag"

          BASE_DIR="$( pwd )"/ 
          DEPS_DIR="$BASE_DIR"deps/ 

          echo "Cloning CLI repo"
          gh repo clone npm/cli

          echo "Prepping CLI repo for release"
          cd cli
          git checkout v"$npm_tag"
          make
          make release


          echo "Removing old npm"
          cd "$DEPS_DIR"
          rm -rf npm/

          echo "Copying new npm"
          tar zxf "$BASE_DIR"cli/release/npm-"$npm_tag".tgz

          echo "Removing CLI workspace"
          cd "$BASE_DIR"
          rm -rf cli

          git add -A deps/npm
          git commit -m "deps: upgrade npm to $npm_tag"
          git rebase --whitespace=fix master
          git push origin "npm-$npm_tag"
          gh_release_body=`gh release view v"$npm_tag" -R npm/cli --json body | jq -r '.body'`

          gh pr create -R "nodejs/node" -B "$base_branch" -H "npm:npm-$npm_tag" --title "deps: upgrade npm to $npm_tag" --body "$gh_release_body"