Skip to content

Commit

Permalink
Clean up github actions ci
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultzer committed Jan 4, 2024
1 parent 6f80c37 commit 2f0eeae
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 31 deletions.
59 changes: 28 additions & 31 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -27,40 +39,25 @@ jobs:
--health-retries 5
strategy:
matrix:
include:
version:
- otp: 26.0
elixir: 1.15.0
os: ubuntu-latest
- otp: 22.0
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
25 changes: 25 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2f0eeae

Please sign in to comment.