Skip to content

chore: example account.controller.ts #42

chore: example account.controller.ts

chore: example account.controller.ts #42

Workflow file for this run

name: CI
on:
pull_request:
branches:
- main
# Needed for nx-set-shas when run on the main branch
permissions:
actions: read
contents: write
checks: write
pull-requests: write
jobs:
main:
runs-on: ubuntu-latest
if: github.head_ref != 'weblate-postybirb-postybirb'
steps:
- name: Check out Git repository
uses: actions/checkout@v4
with:
# Note: By default, the checkout action will only clone the latest commit of the branch, which will cause issues as Nx needs to compute the difference between the base and head. Using the fetch-depth: 0 parameter will clone the entire repository, which is not optimal but functional.
fetch-depth: 0
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v4
with:
cache: yarn
# Note: This flags needed to speed up build
- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline
- name: Set git SHA for NX affected
uses: nrwl/nx-set-shas@v3
# Note: This step is needed for nx affected to work when CI is running on a PR
- name: Track right branch
run: npx exitzero git branch --track main origin/main
- name: Lint changes affected by this pr
run: npx exitzero nx affected --parallel -t lint --fix
# It commits extracted eslint/prettier fixes
- name: Commit changes
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
npx exitzero "git add './' && git commit -m 'ci: prettier and eslint fixes'"
exit 0
- name: Push changes back to PR
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}
- name: Get latest commit SHA
run: |
echo "latest_sha=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
- name: Move checks to the last commit
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const orig_sha = context.payload.pull_request.head.sha
const latest_sha = process.env.latest_sha
console.log({ orig_sha, latest_sha });
if (latest_sha === orig_sha) {
console.log("Latest commit SHA matches original pull request commit SHA, not moving annotations...");
return;
}
const checks_list = await github.rest.checks.listForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: orig_sha
})
try {
const check_run = checks_list.check_runs[0]
} catch (e) {
console.error(e);
console.error({ checks_list });
}
if (!check_run) {
console.log("No check runs found for SHA", orig_sha);
return;
}
const annotations = await github.rest.checks.listAnnotations({
owner: context.repo.owner,
repo: context.repo.repo,
check_run_id: check_run.id,
});
if (annotations.length < 1) {
console.log("Empty annotations for check_run_id", check_run.id)
return;
}
github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Lint',
head_sha: latest_sha,
status: 'completed',
conclusion: annotations.some(annotation => annotation.annotation_level === 'failure') ? 'failure' : 'success',
output: {
title: 'Linting Results',
summary: 'Linting results for the affected files',
annotations: annotations,
},
});
# Actually this does nothing except for ignoring failed pushes
- name: Finish
if: ${{ !cancelled() }}
run: echo 'Done!'