diff --git a/.circleci/config.yml b/.circleci/config.yml index 7b3a9779..92fafb3d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,6 +4,16 @@ version: 2.1 +commands: + check-changed-files-or-halt: + steps: + - run: | + if echo "$(git diff --name-only origin/main HEAD)" | grep -qE '\.github\/.*\.(yaml|yml)$'; then + # if there is a change in the .github folder, halt the build + echo "Stopping build because there is a change in the .github folder" + circleci-agent step halt + fi + jobs: run-tests: parallelism: 1 @@ -21,12 +31,12 @@ jobs: working_directory: ~/app steps: + - checkout + - check-changed-files-or-halt - run: mix local.hex --force - run: mix local.rebar --force - run: mix hex.organization auth coverflex_engineering --key $HEX_API_KEY - - checkout - - restore_cache: keys: - v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }} @@ -61,10 +71,11 @@ jobs: working_directory: ~/app steps: + - checkout + - check-changed-files-or-halt - run: mix local.hex --force - run: mix local.rebar --force - run: mix hex.organization auth coverflex_engineering --key $HEX_API_KEY - - checkout - run: mix do deps.get, deps.compile - run: HEX_API_KEY=$HEX_API_KEY mix hex.publish package --yes diff --git a/.github/workflows/on_pull_request.yaml b/.github/workflows/on_pull_request.yaml new file mode 100644 index 00000000..1658185b --- /dev/null +++ b/.github/workflows/on_pull_request.yaml @@ -0,0 +1,28 @@ +--- +name: On pull request + +on: + workflow_dispatch: + pull_request: + branches: + - main + - hotfix/** + paths-ignore: + - 'infra/**' + - '.github/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + run-tests: + uses: coverflex-tech/global-actions/.github/workflows/elixir_run_tests.yaml@main + with: + ELIXIR_VERSION: 1.13.4 + OTP_VERSION: 24.3.4 + secrets: + CI_PAT: ${{ secrets.CI_PAT }} + OBAN_KEY_FINGERPRINT: ${{ secrets.OBAN_KEY_FINGERPRINT }} + OBAN_LICENSE_KEY: ${{ secrets.OBAN_LICENSE_KEY }} + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} diff --git a/.github/workflows/on_push.yaml b/.github/workflows/on_push.yaml new file mode 100644 index 00000000..afabdb50 --- /dev/null +++ b/.github/workflows/on_push.yaml @@ -0,0 +1,23 @@ +--- +name: On push main + +on: + push: + branches: + - main + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }} + +jobs: + tag-and-publish: + uses: coverflex-tech/global-actions/.github/workflows/elixir_tag_and_publish.yaml@main + with: + ELIXIR_VERSION: 1.13.4 + OTP_VERSION: 24.3.4 + secrets: + OBAN_KEY_FINGERPRINT: ${{ secrets.OBAN_KEY_FINGERPRINT }} + OBAN_LICENSE_KEY: ${{ secrets.OBAN_LICENSE_KEY }} + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} + CI_PAT: ${{ secrets.CI_PAT }}