chore: update test snapshots #154
This file contains 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: Pre-release | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
lerna_publish: | |
runs-on: ubuntu-latest | |
if: ${{github.event.issue.pull_request && contains(github.event.comment.body, '@copilot-robot prerelease')}} | |
steps: | |
- uses: actions/github-script@v6 | |
with: | |
script: | | |
try { | |
const result = await github.rest.reactions.createForIssueComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: context.payload.comment.id, | |
content: "+1" | |
}); | |
return result.data; | |
} catch (err) { | |
core.info(`Failed to set reaction error ${err}`) | |
} | |
env: | |
GITHUB_TOKEN: ${{secrets.ROBOT_GITHUB_TOKEN}} | |
- uses: actions/github-script@v3 | |
id: get-ref-name | |
with: | |
result-encoding: string | |
script: | | |
const result = await github.pulls.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number | |
}); | |
if (result.data.head.ref === "main") { | |
throw new Error("Prereleasing main is unsupported"); | |
} | |
return result.data.head.ref; | |
env: | |
GITHUB_TOKEN: ${{secrets.ROBOT_GITHUB_TOKEN}} | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
ref: ${{steps.get-ref-name.outputs.result}} | |
- name: Configure git | |
run: | | |
git config user.name "${GITHUB_ACTOR}" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY | |
git checkout $BRANCH_NAME | |
echo "Prepublishing $(git branch --show-current) on behalf of ${GITHUB_ACTOR}" | |
env: | |
BRANCH_NAME: ${{steps.get-ref-name.outputs.result}} | |
GITHUB_TOKEN: ${{secrets.ROBOT_GITHUB_TOKEN}} | |
- uses: actions/setup-node@v3 | |
with: | |
always-auth: true | |
node-version: "20.11.1" | |
registry-url: https://registry.npmjs.org | |
- name: Install Dependencies | |
run: npm ci --no-optional | |
- name: Fetch tags | |
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
env: | |
GITHUB_TOKEN: ${{secrets.ROBOT_GITHUB_TOKEN}} | |
- name: Lerna publish | |
id: publish | |
run: | | |
npx lerna publish\ | |
--dist-tag "${BRANCH_NAME}"\ | |
--preid "${BRANCH_NAME}"\ | |
--canary\ | |
-m 'chore(prerelease): publish'\ | |
--yes\ | |
--summary-file | |
env: | |
BRANCH_NAME: ${{steps.get-ref-name.outputs.result}} | |
GITHUB_TOKEN: ${{secrets.ROBOT_GITHUB_TOKEN}} | |
NODE_AUTH_TOKEN: ${{secrets.ROBOT_NPM_TOKEN}} | |
- uses: actions/github-script@v6 | |
if: ${{ success() }} | |
with: | |
github-token: ${{secrets.ROBOT_GITHUB_TOKEN}} | |
script: | | |
try { | |
const fs = require("fs/promises"); | |
let publishResult = await fs.readFile(`./lerna-publish-summary.json`); | |
let packageInfo = JSON.parse(publishResult.toString()); | |
const result = await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: `Hi, @${context.actor}, a pre-release has been published:\n\n${packageInfo.map(package => `- ${package.packageName}@${package.version}`).join("\n")}` | |
}); | |
return result.data; | |
} catch (err) { | |
core.info(`Failed to reply to user with pre-release info ${err}`) | |
} | |
- uses: actions/github-script@v6 | |
if: ${{ failure() }} | |
with: | |
github-token: ${{secrets.ROBOT_GITHUB_TOKEN}} | |
script: | | |
try { | |
const result = await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: `Hi, @${context.actor}, there are no changed packages to publish.` | |
}); | |
} catch (err) { | |
core.info(`Failed to reply to user with pre-release info ${err}`) | |
} |