|
| 1 | +name: publish package to npm |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'version' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +jobs: |
| 12 | + publish: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + - uses: actions/setup-node@v4 |
| 19 | + - name: 'validation' |
| 20 | + uses: actions/github-script@v7 |
| 21 | + env: |
| 22 | + VERSION: ${{ github.event.inputs.version }} |
| 23 | + with: |
| 24 | + script: | |
| 25 | + const version = process.env.VERSION; |
| 26 | +# const permission = await github.rest.repos.getCollaboratorPermissionLevel({ |
| 27 | +# owner: context.repo.owner, |
| 28 | +# repo: context.repo.repo, |
| 29 | +# username: context.actor |
| 30 | +# }); |
| 31 | +# if (permission.data.permission !== 'admin' && permission.data.permission !== 'write') { |
| 32 | +# core.setFailed(`User ${context.actor} does not have write or admin permissions to this repository.`); |
| 33 | +# } |
| 34 | +# const currentBranch = context.ref.replace('refs/heads/', ''); |
| 35 | +# if (currentBranch !== `release/${version}`) { |
| 36 | +# core.setFailed(`Current branch ${currentBranch} does not match release/${version}`); |
| 37 | +# } |
| 38 | +# const pullRequests = await github.rest.pulls.list({ |
| 39 | +# owner: context.repo.owner, |
| 40 | +# repo: context.repo.repo, |
| 41 | +# state: 'open', |
| 42 | +# sort: 'created', |
| 43 | +# direction: 'desc', |
| 44 | +# }); |
| 45 | +# const pr = pullRequests.data.find(pr => pr.head.ref === currentBranch && pr.base.ref === 'main'); |
| 46 | +# if (!pr) { |
| 47 | +# core.setFailed(`No open pull request found for ${currentBranch} to main`); |
| 48 | +# } |
| 49 | +# core.exportVariable('PR_NUMBER', pr.number); |
| 50 | + - run: yarn install --frozen-lockfile |
| 51 | + - name: 'set environments' |
| 52 | + run: | |
| 53 | +# echo "//registry.npmjs.org/:_authToken=${{ secrets.npm_token }}" >> .npmrc |
| 54 | +# git config --global user.email "[email protected]" |
| 55 | +# git config --global user.name "sendbird-sdk-deployment" |
| 56 | + - name: 'publish to npm' |
| 57 | + env: |
| 58 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + VERSION: ${{ github.event.inputs.version }} |
| 60 | + run: | |
| 61 | +# yarn lerna version "$VERSION" --yes |
| 62 | +# yarn lerna publish from-git --yes |
| 63 | + - name: 'approve a pull request' |
| 64 | + env: |
| 65 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + PR_NUMBER: ${{ env.PR_NUMBER }} |
| 67 | + run: | |
| 68 | +# gh pr review "$PR_NUMBER" --approve --body "approved by automation" |
0 commit comments