Fix SSR #5198
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: CI | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the main and next branches | |
on: | |
push: | |
branches: | |
- main | |
- next | |
- v1 | |
paths-ignore: | |
- '**/docs/**' | |
- '**.md' | |
pull_request: | |
types: [opened, synchronize, reopened, edited, ready_for_review] | |
paths-ignore: | |
- '**/docs/**' | |
- '**.md' | |
# Setup concurrency to the ref (branch / tag) that triggered the workflow | |
concurrency: ci-${{ github.ref }} | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "CI" | |
CI: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Do not run if the pull request is a draft | |
if: ${{ !github.event.pull_request.draft && !contains(github.event.commits[0].message, '[skip build]') }} | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
# Use fetch-depth: 0 so that all tags and branches are fetched | |
# Use persist-credentials: false so that the make release step uses another personal access | |
# token which has admin access and can push the version commit without the restriction | |
# of creating a pull-request. | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
registry-url: 'https://registry.npmjs.org' | |
scope: '@farfetch' | |
cache: 'yarn' | |
always-auth: true | |
# This is needed for lerna to commit and push the | |
# new version when making a release | |
- name: Checkout the source branch in a pull request for lerna | |
if: ${{ github.event_name == 'pull_request' && startsWith(github.head_ref, 'rc/') }} | |
run: | | |
git checkout "${{ github.head_ref }}" | |
# This is needed for lerna to commit and push the | |
# new version when making a release | |
- name: Checkout the branch for pushes to a branch for lerna | |
if: ${{ github.event_name == 'push' }} | |
run: | | |
git checkout "${{ github.ref_name }}" | |
# Retrieves the commit message to be used in the | |
# make release step | |
- name: Get commit message | |
id: get-commit-message | |
run: | | |
COMMIT_MSG=$(git log -1 --pretty=format:"%s") | |
echo "Commit message is: ${COMMIT_MSG})" | |
echo ::set-output name=message::${COMMIT_MSG} | |
- name: Install dependencies | |
run: yarn install --ignore-engines --frozen-lockfile | |
- name: Lint | |
run: yarn lint | |
- name: Test | |
run: yarn test --ci | |
# Only make a release if it is a run of the 'main' or 'next' branches | |
# or a pull request that contains a 'chore: make release' message | |
- name: Make release | |
if: | | |
github.ref_name == 'main' || | |
github.ref_name == 'next' || | |
github.ref_name == 'v1' || | |
(github.event_name == 'pull_request' && startsWith(github.head_ref, 'rc/')) | |
env: | |
MAKE_RELEASE_COMMIT_MESSAGE: 'chore: make release' | |
PUBLISH_COMMIT_MESSAGE: 'chore: publish [skip build]' | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }} | |
GIT_AUTHOR_NAME: ${{ secrets.RELEASE_BOT_GIT_NAME }} | |
GIT_AUTHOR_EMAIL: ${{ secrets.RELEASE_BOT_GIT_EMAIL }} | |
GIT_COMMITTER_NAME: ${{ secrets.RELEASE_BOT_GIT_NAME }} | |
GIT_COMMITTER_EMAIL: ${{ secrets.RELEASE_BOT_GIT_EMAIL }} | |
run: | | |
git remote set-url origin "https://${GITHUB_TOKEN}@github.com/Farfetch/blackout.git" | |
SOURCE_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) | |
if [[ ${SOURCE_BRANCH_NAME} = main || ${SOURCE_BRANCH_NAME} = v1 ]]; then | |
npx lerna publish --conventional-commits --message "${PUBLISH_COMMIT_MESSAGE}" --no-verify-access --yes | |
else | |
if [[ ${SOURCE_BRANCH_NAME} = next ]]; then | |
PRE_ID=next | |
else | |
PRE_ID=rc | |
fi | |
npx lerna publish --conventional-commits --conventional-prerelease --no-verify-access --preid ${PRE_ID} --pre-dist-tag ${PRE_ID} --message "${PUBLISH_COMMIT_MESSAGE}" --yes | |
fi |