Skip to content

Commit

Permalink
Merge pull request #9 from ripple0328/sweep/ci-pipeline-release-tagging
Browse files Browse the repository at this point in the history
Add CI Pipeline and Automatic Release Tagging
  • Loading branch information
ripple0328 authored Jul 8, 2023
2 parents b6a3f7d + 2cae0c5 commit 7a757a5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2

- name: Setup Elixir
uses: actions/setup-elixir@v1
with:
elixir-version: 1.15.2
otp-version: 26.0.1

- name: Install Dependencies
run: mix deps.get

- name: Run Tests
run: mix test

- name: Deploy
run: mix release
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image
# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20230522-slim - for the release image
# - https://pkgs.org/ - resource for finding needed packages
# - Ex: hexpm/elixir:1.15.2-erlang-26-debian-bullseye-20230522-slim
#
# - Ex: hexpm/elixir:1.15.0-erlang-26.0.1-debian-bullseye-20230522-slim
ARG ELIXIR_VERSION=1.15.2
ARG OTP_VERSION=26
ARG OTP_VERSION=26.0.1

ARG DEBIAN_VERSION=bullseye-20230522-slim

ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
Expand Down
15 changes: 12 additions & 3 deletions lib/outdoor/release.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
defmodule Outdoor.Release do
@moduledoc """
@moduledoc '''
Used for executing DB release tasks when run in production without Mix
installed.
"""
'''
@app :outdoor

def migrate do
Expand All @@ -18,11 +18,20 @@ defmodule Outdoor.Release do
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
end

def generate_tag do
{message, 0} = System.cmd("git", ["log", "-1", "--pretty=%B"])
System.cmd("git", ["tag", String.trim(message)])
end

def push_tags do
System.cmd("git", ["push", "--tags"])
end

defp repos do
Application.fetch_env!(@app, :ecto_repos)
end

defp load_app do
Application.load(@app)
end
end
end

0 comments on commit 7a757a5

Please sign in to comment.