Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Publish canary version on PRs to develop #1334

Closed
wants to merge 12 commits into from
48 changes: 48 additions & 0 deletions .github/workflows/publish-canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish Canary

on:
push:
Copy link
Member

@adrien2p adrien2p Jun 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:
on: ["push","pull_request"] if it is possible? 😊

branches: [develop]
pull_request:
branches: [develop]
workflow_run:
workflows: ["Medusa Pipeline"]
types:
- completed

jobs:
publish:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v2.3.5
with:
fetch-depth: 0

- name: Setup Node.js environment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: we should probably add a step to stop previous same workflow in order to avoid situations where we push 10 new versions when we merge ten branches 😅

uses: actions/setup-node@v2.4.1
with:
node-version: "14"
cache: "yarn"
registry-url: "https://registry.npmjs.org"
- name: "Get Branch Name"
run: |
BRANCH_NAME="${GITHUB_HEAD_REF}"
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
- name: Format Version Name
run: |
VERSION_NAME=`echo ${{ env.BRANCH_NAME }} | sed "s/[/_]/-/g"`
echo "VERSION_NAME=${VERSION_NAME}" >> $GITHUB_ENV
- name: Authenticate with NPM
run: |
echo "@oliverjuhl:registry=http://registry.npmjs.org/" > .npmrc
echo "registry=http://registry.npmjs.org/" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish Canary
run: lerna publish --yes --canary --preid ${{ env.VERSION_NAME }} --dist-tag ${{ env.VERSION_NAME }} --force-publish="*"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}