Skip to content

Instantly share code, notes, and snippets.

@qpre
Created January 28, 2020 15:07
Show Gist options
  • Save qpre/817b8050e90aa8a67c81c25cc3f88500 to your computer and use it in GitHub Desktop.
Save qpre/817b8050e90aa8a67c81c25cc3f88500 to your computer and use it in GitHub Desktop.
GitHub Actions for Elixir/Phoenix test/build/release + release on GitHub
name: Elixir CI
on: push
jobs:
test:
runs-on: ${{ matrix.os }}
name: OTP ${{ matrix.otp }} | Elixir ${{ matrix.elixir }} | Node ${{ matrix.node }} | OS ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04]
otp: [22.x]
elixir: [1.9.x]
node: [12.x]
services:
db:
image: postgres:11
ports: ['5432:5432']
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v1.0.0
- uses: actions/setup-elixir@v1.0.0
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: |
mix local.rebar --force
mix local.hex --force
mix deps.get
yarn --cwd assets install
- name: Run tests
run: |
mix compile --warnings-as-errors
mix format --check-formatted
mix test
env:
MIX_ENV: test
- name: Prepare release
run: |
export SECRET_KEY_BASE=$( mix phx.gen.secret )
mix compile
cd assets && npm install && npm run deploy
cd ../
mix phx.digest
mix release
env:
MIX_ENV: prod
DATABASE_URL: ecto://USER:PASS@HOST/database
- name: Archive release
run: |
zip -r platform-api _build
- name: Create Github Release
id: create_release
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Github Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./platform-api.zip
asset_name: platform-api.zip
asset_content_type: application/zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment