Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 0 additions & 195 deletions .circleci/config.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/actions/setup_elixir/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Setup Elixir App

runs:
using: "composite"
steps:
- uses: erlef/setup-elixir@v1
with:
elixir-version: '1.15'
otp-version: '26'

- uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-deps-${{ hashFiles('**/mix.lock') }}

- uses: actions/cache@v4
with:
path: _build
key: ${{ runner.os }}-build-${{ github.sha }}

- run: mix deps.get
shell: bash

- run: mix compile --warnings-as-errors
shell: bash


42 changes: 42 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and Test

on:
push:
branches:
- main
pull_request:

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Elixir
uses: ./.github/actions/setup_elixir

- name: Run tests
run: mix test

- name: Read VERSION file and create tag
if: github.ref == 'refs/heads/main' && success()
run: |
TAG="v$(cat VERSION | tr -d '[:space:]')"
echo "Using tag: $TAG"

git config user.name "github-actions"
git config user.email "github-actions@github.com"

git fetch --tags

if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists. Skipping."
else
git tag "$TAG"
git push origin "$TAG"
echo "Tag $TAG pushed."
fi
100 changes: 62 additions & 38 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,73 @@
name: build
name: Release Docker Image

on:
push:
branches:
- main
tags:
- 'v*'

jobs:
tag-release:
release:
name: Build, Push Docker Image, and Deploy
runs-on: ubuntu-latest
outputs:
release-version: ${{ steps.release-version.outputs.version }}

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

# Tag new release
- name: Set up Node.js
uses: actions/setup-node@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
node-version: 14
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}

- name: Build and push docker image
env:
MIX_ENV: prod
APP_NAME: moon
SERVICE_NAME: moon
DOCKER_ORG: ${{ secrets.DOCKER_USER }}
APP_VSN: ${{ github.ref_name }}
run: |
scripts/deploy/docker-build push $APP_VSN

- name: Install Semantic Release, plugins and preset
working-directory: .
- name: Setup robot SSH key
run: |
npm install -g \
semantic-release@18.0.0 \
conventional-changelog-conventionalcommits@4.6.1

# - name: Run Sematic Release
# working-directory: .
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: semantic-release --branches main

# # Get new release version
# - name: Get release tag
# id: release-tag
# uses: WyriHaximus/github-action-get-previous-tag@v1.1

# - name: Get release version
# id: release-version
# uses: actions/github-script@v6
# with:
# script: |
# core.setOutput(
# 'version',
# '${{ steps.release-tag.outputs.tag }}'.slice(1)
# )
echo "$ROBOT_SSH_KEY" | base64 -d > $HOME/.ssh/id_rsa.robot
chmod 600 $HOME/.ssh/id_rsa.robot
echo -e "Host *\n IdentityFile $HOME/.ssh/id_rsa.robot\n IdentitiesOnly yes" > $HOME/.ssh/config
eval "$(ssh-agent -s)" && ssh-add $HOME/.ssh/id_rsa.robot

- name: Setup deploy tool auth
run: echo "{\"user\":\"$DEPLOY_USER\", \"pass\":\"$DEPLOY_PASS\"}" > $HOME/.deploy_auth

- name: Deploy
run: ./scripts/deploy/stacks-deploy ${{ github.ref_name }}

- name: Restore node_modules cache
uses: actions/cache@v3
with:
path: node_modules
key: v13-node_modules-${{ hashFiles('package-lock.json') }}
restore-keys: |
v13-node_modules-

- name: Restore mix.lock cache
uses: actions/cache@v3
with:
path: _build
key: v13-build_test-${{ hashFiles('mix.lock') }}
restore-keys: |
v13-build_test-

- name: Hex auth
run: mix hex.organization auth coingaming --key $HEX_API_KEY

- name: Semantic Release
env:
MIX_ENV: test
run: mix semantic.release

- name: Save node_modules cache
uses: actions/cache@v3
with:
path: node_modules
key: v13-node_modules-${{ hashFiles('package-lock.json') }}
Loading
Loading