From 2f0eeae6b0cc0c1b94a5264dcc2dd6d76327375f Mon Sep 17 00:00:00 2001 From: Dan Schultzer <1254724+danschultzer@users.noreply.github.com> Date: Thu, 4 Jan 2024 15:16:05 -0800 Subject: [PATCH] Clean up github actions ci --- .github/workflows/build.yml | 59 +++++++++++++++++------------------ .github/workflows/publish.yml | 25 +++++++++++++++ 2 files changed, 53 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a88282d1..4d0141a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,16 +1,28 @@ name: CI -on: +on: push: + branches: [ main ] pull_request: - release: - types: - - published + workflow_call: jobs: + lint: + runs-on: ubuntu-latest + name: Linter + env: + MIX_ENV: test + steps: + - uses: actions/checkout@v3 + - uses: erlef/setup-beam@v1 + with: + otp-version: 26.0 + elixir-version: 1.15 + - run: mix deps.get + - run: mix compile --warnings-as-errors + - run: mix credo --ignore design.tagtodo + test: - # This ensures we run the test for only the PR or the push - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name services: postgres: image: postgres:latest @@ -27,7 +39,7 @@ jobs: --health-retries 5 strategy: matrix: - include: + version: - otp: 26.0 elixir: 1.15.0 os: ubuntu-latest @@ -35,32 +47,17 @@ jobs: elixir: 1.12.0 # It's necessary to run on ubunto 20.04 for OTP 20 - 25 # See https://github.com/erlef/setup-beam - os: ubuntu-20.04 - runs-on: ${{ matrix.os }} - name: OTP ${{ matrix.otp }} / Elixir ${{ matrix.elixir }} - steps: - - uses: actions/checkout@v3 - - uses: erlef/setup-beam@v1 - with: - otp-version: ${{ matrix.otp }} - elixir-version: ${{ matrix.elixir }} - - run: mix deps.get - - run: mix test - env: - POSTGRES_URL: ecto://postgres:postgres@localhost/pow_test - - run: MIX_ENV=test mix credo --ignore design.tagtodo - deploy: - needs: test - runs-on: ubuntu-latest - if: github.event_name == 'release' && github.event.action == 'published' - name: Deploy published release + os: ubuntu-20.04 + runs-on: ${{ matrix.version.os }} + name: OTP ${{matrix.version.otp}} / Elixir ${{matrix.version.elixir}} env: - HEX_API_KEY: ${{ secrets.HEX_API_KEY }} + MIX_ENV: test + POSTGRES_URL: ecto://postgres:postgres@localhost/pow_test steps: - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: - otp-version: 25.0 - elixir-version: 1.14.0 - - run: mix deps.get - - run: mix hex.publish --yes + otp-version: ${{matrix.version.otp}} + elixir-version: ${{matrix.version.elixir}} + - run: mix deps.get mix compile --warnings-as-errors + - run: mix test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..fba71c74 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,25 @@ +name: Publish + +on: + release: + types: + - published + +jobs: + test: + uses: ./.github/workflows/ci.yml + + publish: + needs: test + runs-on: ubuntu-latest + name: Publish release + env: + HEX_API_KEY: ${{secrets.HEX_API_KEY}} + steps: + - uses: actions/checkout@v2 + - uses: erlef/setup-beam@v1 + with: + otp-version: 26.0 + elixir-version: 1.15 + - run: mix deps.get + - run: mix hex.publish --yes \ No newline at end of file