diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml new file mode 100644 index 0000000..95547dc --- /dev/null +++ b/.github/workflows/CICD.yml @@ -0,0 +1,57 @@ +name: "Github Workflows syntax" + +on: + pull_request: + +env: + NODE_VERSION: 20 + PYTHON_VERSION: '3.12' + +jobs: + pre-commit: + name: 'Execute pre-commit rules' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Run pre-commit rules + uses: pre-commit/action@v3.0.0 + + workflow-validation: + name: Github Action Workflows validation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + - uses: reviewdog/action-actionlint@v1 + + tag-release: + name: Github release + runs-on: ubuntu-latest + if: ${{ github.ref_name == 'main' }} + needs: + - pre-commit + - workflow-validation + permissions: + contents: write + outputs: + released_version: ${{ steps.release.outputs.version }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + persist-credentials: false + + - name: "Semantic release" + id: release + uses: "meero-com/github-actions-shared-workflows/actions/release/semantic@main" + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + npm-token: ${{ secrets.NPM_TOKEN }} + branch: 'main' diff --git a/.github/workflows/workflows.yml b/.github/workflows/workflows.yml deleted file mode 100644 index 2b77fdb..0000000 --- a/.github/workflows/workflows.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -name: "Github Workflows syntax" - -on: - pull_request: - -jobs: - workflow-validation: - name: Github Action Workflows validation - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - uses: reviewdog/action-actionlint@v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..745ae62 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +--- +default_install_hook_types: [commit-msg, pre-commit] +repos: + - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook + rev: v9.4.0 + hooks: + - id: commitlint + stages: [commit-msg] + additional_dependencies: ['@commitlint/config-conventional'] + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.28.1 + hooks: + - id: check-github-workflows + - id: check-github-actions + files: action\.(yml|yaml) diff --git a/README.md b/README.md index 5158a36..5d7d1e5 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,11 @@ Beware of using a `@ref` (`@main` in the example above) which suits your stabili * Use `@main` if you always want to use the latest version of the workflow. * Use `@` if you wan to use a specific frozen version of the workflow. + +## Local Development + +This repository use pre-commit + +- [install pre-commit](https://pre-commit.com/index.html#install) +- run once `pre-commit install` to automatically execute pre-commit hooks at commit +- run `pre-commit run -a` whenever you want to run hooks on the complete repository diff --git a/actions/precommit/render-openapi-template/action.yml b/actions/precommit/render-openapi-template/action.yml index 6a70f98..a9d4331 100644 --- a/actions/precommit/render-openapi-template/action.yml +++ b/actions/precommit/render-openapi-template/action.yml @@ -28,14 +28,13 @@ outputs: description: "Api Gateway file artifact name" value: openapi-${{ inputs.OPENAPI_API_NAME }}-${{ inputs.version_identifier }}.json -env: - PYTHON_VERSION: '3.10' - runs: using: "composite" steps: - name: Set up Python uses: actions/setup-python@v4 + env: + PYTHON_VERSION: '3.10' with: python-version: ${{ env.PYTHON_VERSION }} diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..eb514e0 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,6 @@ +module.exports = { + extends: ['@commitlint/config-conventional'], + rules: { + 'scope-empty': [2, 'never'], + } +};