Add [email protected] behind AB test #880
Workflow file for this run
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: Publish Beta Package | |
# This workflow is triggered on a label being added to a PR, and will publish a beta version of the bundle to npm | |
# Use `pnpm changeset add` to add a new change | |
# This action will release the changeset as a pre-release, and add a comment to the PR with the version number | |
on: | |
pull_request: | |
types: [labeled] | |
permissions: write-all | |
jobs: | |
has-permission: | |
name: Check permissions | |
runs-on: ubuntu-latest | |
if: github.event.label.name == '[beta] @guardian/commercial' | |
steps: | |
- name: Check if organization member | |
id: is_organization_member | |
uses: JamesSingleton/[email protected] | |
with: | |
organization: guardian | |
username: ${{ github.actor }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
release: | |
name: '@guardian/commercial' | |
runs-on: ubuntu-latest | |
needs: has-permission | |
if: github.event.label.name == '[beta] @guardian/commercial' | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
# Temporarily force newer version of corepack | |
# See https://github.com/guardian/support-service-lambdas/pull/2666 | |
- run: npm install --global [email protected] | |
- name: Set up Node | |
uses: ./.github/actions/setup-node-env | |
- name: Build package | |
run: pnpm build | |
- name: Version | |
run: pnpm changeset version --snapshot beta | |
- name: Create Release | |
uses: changesets/[email protected] | |
id: changeset | |
with: | |
publish: pnpm changeset publish --tag beta | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Comment on PR | |
uses: actions/[email protected] | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const publishedPackages = ${{ steps.changeset.outputs.publishedPackages }}; | |
if(publishedPackages.length === 0) { | |
throw new Error('No packages published, did you forget to add a changeset?'); | |
} | |
const version = publishedPackages[0].version; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `🚀 \`${version}\` published to npm as a beta release | |
To install the beta version, run one of the following commands in your project directory: | |
\`\`\` | |
npm install @guardian/commercial@${version} | |
pnpm add @guardian/commercial@${version} | |
yarn add @guardian/commercial@${version} | |
\`\`\` | |
` | |
}) | |
- name: Remove label | |
uses: actions/[email protected] | |
if: always() | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.rest.issues.removeLabel({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: '[beta] @guardian/commercial' | |
}) |