Skip to content

Commit

Permalink
[#14] Use github actions for AWS deployment (#29)
Browse files Browse the repository at this point in the history
Created new workflow "CI - Build release asset" at build.yml.
  • Loading branch information
diegomanuel authored Dec 21, 2019
1 parent 5993852 commit e719228
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 6 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CI - Build release asset

on:
release:
types: [published]

jobs:
build:
name: Build OTP ${{ matrix.otp }} | Elixir ${{ matrix.elixir }} | Node ${{ matrix.node }} | OS ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04]
otp: [22.0.7]
elixir: [1.9.1]
node: [12.8.0]

steps:
- uses: actions/checkout@v1
- uses: actions/[email protected]
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 archive.install --force https://raw.githubusercontent.com/phoenixframework/archives/master/phx_new.ez
mix deps.get
npm install
- name: Check code format
run: mix format --check-formatted
- name: Run tests
run: mix test

- name: Build release
run: |
export SECRET_KEY_BASE=$(MIX_ENV=test mix phx.gen.secret)
mix compile
npm run deploy
mix phx.digest
mix release
env:
MIX_ENV: prod

- name: Build package
id: build_package
run: |
timestamp="`date '+%Y%m%d-%H%M%S'`"
version="$timestamp-`echo $REVISION | cut -c1-8 `"
apppath="$RELEASE_PATH/$APPLICATION"
archive="$APPLICATION-$version.tar.gz"
cp cooperatives.yml $apppath/
echo $REVISION > $apppath/REVISION
echo $version > $apppath/VERSION
tar -zcf $archive -C $RELEASE_PATH $APPLICATION
echo "::set-output name=timestamp::$timestamp"
echo "::set-output name=version::$version"
echo "::set-output name=archive::$archive"
echo "Release package built at $archive"
env:
REVISION: ${{ github.sha }}
RELEASE_PATH: _build/prod/rel
APPLICATION: coophub

- name: Upload package artifact
uses: actions/upload-artifact@v1
with:
name: coophub-release
path: ${{ steps.build_package.outputs.archive }}

- name: Upload release asset
id: upload_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.build_package.outputs.archive }}
asset_name: ${{ steps.build_package.outputs.archive }}
asset_content_type: application/tar+gzip

- name: Dispatch release
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
repository: ${{ secrets.REPO_DISPATCH_PATH }}
event-type: coophub-release
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
12 changes: 6 additions & 6 deletions .github/workflows/elixir.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: Elixir CI
name: CI - Test

on: [pull_request, push]
on: push

jobs:
build:

test:
name: Run elixir tests
runs-on: ubuntu-latest

container:
image: elixir:1.9.1-slim

steps:
- uses: actions/checkout@v1
- name: Install Dependencies
- name: Install dependencies
run: |
mix local.rebar --force
mix local.hex --force
mix deps.get
- name: Check code format
run: mix format --check-formatted
- name: Run Tests
- name: Run tests
run: mix test

0 comments on commit e719228

Please sign in to comment.