Skip to content

chore(release): [skip-github-pipeline] #39

chore(release): [skip-github-pipeline]

chore(release): [skip-github-pipeline] #39

Workflow file for this run

name: Run conventional-prerelease on merge to main
on:
push:
branches:
- main
permissions:
pull-requests: write
issues: write
repository-projects: write
deployments: write
contents: write
statuses: write
actions: write
checks: read
env:
HUSKY: 0
jobs:
check-commit-message:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v3
if: ${{ github.event_name != 'pull_request' }}
with:
token: ${{ secrets.GH_ACTIONS_PERSONAL_ACCESS_TOKEN }}
fetch-depth: 0
ref: main
- name: Check commit message
id: check_commit_message
run: |
COMMIT_MESSAGE=$(git log --format=%B -n 1 ${{ github.sha }})
if [[ $COMMIT_MESSAGE == *"skip-github-pipeline"* ]]; then
echo "Commit message contains 'skip-github-pipeline', workflow should be canceled."
echo "should_cancel=true" >> $GITHUB_ENV
else
echo "Commit message dos not contain 'skip-github-pipeline', workflow should proceed."
echo "should_cancel=false" >> $GITHUB_ENV
fi
- name: Cancel workflow
if: env.should_cancel == 'true'
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GH_ACTIONS_PERSONAL_ACCESS_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel
pre-release:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ github.workspace }}
strategy:
matrix:
node-version: [18]
npm-version: [8]
yarn-version: ['1.22.x']
pnpm-version: [8]
steps:
- name: Checkout [Default Branch]
uses: actions/checkout@v3
if: ${{ github.event_name != 'pull_request' }}
with:
token: ${{ secrets.GH_ACTIONS_PERSONAL_ACCESS_TOKEN }}
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: ${{ github.base_ref }}
- name: Detect package manager
id: package_manager
run: |
echo "package_manager=$([[ -f ./yarn.lock ]] && echo "yarn" || ([[ -f ./pnpm-lock.yaml ]] && echo "pnpm") || echo "npm")" >> $GITHUB_ENV
- name: Set node/npm/yarn versions using volta
uses: volta-cli/action@v3
with:
node-version: '${{ matrix.node-version }}'
npm-version: '${{ matrix.npm-version }}'
yarn-version: '${{ matrix.yarn-version }}'
pnpm-version: '${{ matrix.pnpm-version }}'
- name: Install PNPM
if: env.package_manager == 'pnpm'
uses: pnpm/[email protected]
with:
version: '${{ matrix.pnpm-version }}'
- name: Print node/npm/yarn/pnpm versions
id: versions
run: |
node_ver=$( node --version )
yarn_ver=$( yarn --version || true )
pnpm_ver=$( pnpm --version || true )
echo "Node: ${node_ver:1}"
echo "NPM: $(npm --version )"
if [[ $yarn_ver != '' ]]; then echo "Yarn: $yarn_ver"; fi
if [[ $pnpm_ver != '' ]]; then echo "PNPM: $pnpm_ver"; fi
echo "node_version=${node_ver:1}" >> $GITHUB_ENV
- name: Use the node_modules cache if available [npm]
if: env.package_manager == 'npm'
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.node_version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ env.node_version }}-
- name: Use the node_modules cache if available [pnpm]
if: env.package_manager == 'pnpm'
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-node-${{ env.node_version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-${{ env.node_version }}-
- name: Get yarn cache directory path
if: env.package_manager == 'yarn'
id: yarn-cache-dir-path
run: echo "yarn_cache_dir_path=$(yarn cache dir)" >> $GITHUB_ENV
- name: Use the node_modules cache if available [yarn]
if: env.package_manager == 'yarn'
uses: actions/cache@v2
with:
path: ${{ env.yarn_cache_dir_path }}
key: ${{ runner.os }}-node-${{ env.node_version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-${{ env.node_version }}-
- name: Override fake nx token
run: |
bash scripts/nx/set-nx-cloud-token.sh --access-token=${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
- name: Install dependencies
run: |
if [ "${{ env.package_manager == 'yarn' }}" == "true" ]; then
echo "Running yarn install --frozen-lockfile"
yarn install --frozen-lockfile
elif [ "${{ env.package_manager == 'pnpm' }}" == "true" ]; then
echo "Running pnpm install --frozen-lockfile"
pnpm install --frozen-lockfile
else
echo "Running npm ci"
npm ci
fi
- name: Extract branch name
run: |
echo $GITHUB_REF
echo $GITHUB_HEAD_REF
branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
echo "branch_name=$branch_name" >> $GITHUB_ENV
- name: Check affected
run: |
NX_BRANCH=${{ env.branch_name }} npx nx affected --target lint --parallel 3
NX_BRANCH=${{ env.branch_name }} npx nx affected --target test --parallel 3 --ci --code-coverage
NX_BRANCH=${{ env.branch_name }} npx nx affected --target build --parallel 3
- name: Release
if: ${{ success() && (github.event_name != 'pull_request' || github.event.action == 'closed' && github.event.pull_request.merged == true) }}
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_PERSONAL_ACCESS_TOKEN }}
run: |
git status
git diff
pnpm git:discard:all
git status
git diff
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor}}@users.noreply.github.com"
pnpm conventional-prerelease
- name: Override nx token back to fake value # Avoid leaking the token
run: |
bash scripts/nx/set-nx-cloud-token.sh --access-token=fake-token