This repository (mauriciabad/my-actions
) contains reusable GitHub Actions for my projects.
Sample workflows you can copy paste to your repo.
- Copy this code into a new workflow in your repository: auto-merge-dependabot.
- Create a Personal Access Token with
push
permission and save it as a secretPUSH_TOKEN
in the repository.
Complete set of jobs for a CI of a project using Vite, Vue.js 3, Cypress, and npm.
It has jobs for: lint
, type-check
, unit-test
, and e2e-test
.
After linting, it commits the autofixed changes to the same branch.
If the E2E tests fail, it uploads screenshots and videos artifacts. These are only avilable for 3 days.
Runs Lighthouse CI when all tests pass.
-
Create this gh action workflow file:
# .github/workflows/ci.yml name: CI on: push jobs: ci: name: CI uses: mauriciabad/my-actions/.github/workflows/ci-vite.yml@main with: lighthouse: false secrets: LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
-
Configure Lighthouse:
- Install the Lighthouse CI GitHub App
- Copy the token provided on the authorization confirmation page and add it to your build environment as
LHCI_GITHUB_APP_TOKEN
. - Create a
lighthouserc.yaml
file on the project root with this contents:
ci: preset: lighthouse:all upload: target: temporary-public-storage
Name | Type | Default | Description |
---|---|---|---|
autofix |
boolean | true | Commit automatic fixes after lint |
lint |
boolean | true | Run lint job |
type-check |
boolean | true | Run type-check job |
unit-test |
boolean | true | Run unit-test job |
e2e-test |
boolean | true | Run e2e-test job |
lighthouse |
boolean | true | Run lighthouse job. Must pass LHCI_GITHUB_APP_TOKEN secret |
Name | Description |
---|---|
LHCI_GITHUB_APP_TOKEN |
Lighthouse token provided on the authorization confirmation page after the installation of the Lighthouse CI GitHub App. More detais here. |
List of avilable actions.
This action installs node and the npm dependencies.
- Grant access to the repository code.
- Sets-up npm cache.
- Installs Node.js based on the version specified in the file
.nvmrc
. - Runs
npm ci
# .github/workflows/ci.yaml
name: CI
on: push
jobs:
unit-tests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: ⚙️ Setup
uses: mauriciabad/my-actions/setup-npm@main
- name: 🧪 Test
run: npm run test:unit