chore(release): [skip-github-pipeline] #93
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: 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 | |
JWT_PRIVATE_KEY: ${{ secrets.JWT_PRIVATE_KEY }} | |
JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }} | |
POSTGRES_USER: ${{ secrets.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
POSTGRES_DB: ${{ secrets.POSTGRES_DB }} | |
POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }} | |
POSTGRES_SCHEMA: ${{ secrets.POSTGRES_SCHEMA }} | |
API_KEY: ${{ secrets.API_KEY }} | |
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: Install PNPM | |
uses: pnpm/[email protected] | |
with: | |
version: '8' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Set up environment variables | |
run: | | |
echo "DATABASE_URL=postgresql://${{ secrets.POSTGRES_USER }}:${{ secrets.POSTGRES_PASSWORD }}@localhost:5432/${{ secrets.POSTGRES_DB }}?schema=${{ secrets.POSTGRES_SCHEMA }}" >> $GITHUB_ENV | |
- name: Setting up docker compose | |
run: docker compose up -d | |
- name: Setting up prisma postgresql database | |
run: | | |
pnpm run prisma:core:schema:generate | |
pnpm run prisma:core:schema:migrate | |
- name: Override fake nx token | |
run: | | |
bash scripts/nx/set-nx-cloud-token.sh --access-token=${{ secrets.NX_CLOUD_ACCESS_TOKEN }} | |
- 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 |