-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from sgobotta/feature/add-cd
Revamp
- Loading branch information
Showing
83 changed files
with
9,317 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# App | ||
APP_NAME=livedj | ||
export MIX_ENV=dev | ||
export APP_HOST=0.0.0.0 | ||
export PHX_HOST=0.0.0.0 | ||
export STAGE=local | ||
|
||
# Email configuration | ||
export LIVEDJ_FROM_EMAIL=[email protected] | ||
|
@@ -14,7 +15,11 @@ export DB_DATABASE=livedj_dev | |
export DB_HOSTNAME=localhost | ||
|
||
# Cache service | ||
export REDIS_HOST=localhost | ||
export REDIS_PASS=123456 | ||
|
||
# Misc | ||
export UPLOADS_PATH=priv/static/uploads | ||
|
||
# Youtube API Key | ||
export YOUTUBE_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Deploy | ||
STAGE=local | ||
|
||
# App | ||
PHX_HOST=0.0.0.0 | ||
MIX_ENV=prod | ||
STAGE=local | ||
SECRET_KEY_BASE=$(elixir --eval 'IO.puts(:crypto.strong_rand_bytes(64) |> Base.encode64(padding: false))') | ||
PHX_SERVER=true | ||
UPLOADS_PATH="priv/static/uploads/" | ||
|
||
# Docker | ||
CONTAINER_PORT=5000 | ||
INTERNAL_PORT=5001 | ||
|
||
# Email configuration | ||
[email protected] | ||
SENDGRID_API_KEY=xxxxxxxxxxxxxxxxxxxxxxx | ||
|
||
# Database | ||
# Either use url or the standard db vars | ||
# DATABASE_URL=ecto://postgres:postgres@postgres/db_local | ||
DB_USERNAME=postgres | ||
DB_PASSWORD=postgres | ||
DB_DATABASE=livedj_local | ||
DB_HOSTNAME=postgres | ||
|
||
# Cache service | ||
REDIS_HOST=redis | ||
REDIS_PASS=123456 | ||
|
||
# Youtube API Key | ||
YOUTUBE_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,12 @@ inputs: | |
POSTGRES_USER: | ||
description: Postgres database user | ||
required: true | ||
REDIS_HOST: | ||
description: The Redis host | ||
required: true | ||
REDIS_PASS: | ||
description: The Redis pass | ||
required: true | ||
STAGE: | ||
default: local | ||
description: The production environment | ||
|
@@ -117,7 +123,7 @@ runs: | |
./entrypoint.sh setup_db | ||
env: | ||
# Application env | ||
APP_HOST: 0.0.0.0 | ||
PHX_HOST: 0.0.0.0 | ||
SECRET_KEY_BASE: some-secret-key | ||
STAGE: local | ||
# Postgres env | ||
|
@@ -128,6 +134,7 @@ runs: | |
# Sendgrid env | ||
LIVEDJ_FROM_EMAIL: [email protected] | ||
SENDGRID_API_KEY: some-sendgrid-api-key | ||
MIX_ENV: ${{ inputs.MIX_ENV }} | ||
|
||
# Test release ------------------------------------------------------------- | ||
- name: Test release | ||
|
@@ -138,7 +145,7 @@ runs: | |
id: test-application | ||
env: | ||
# Application env | ||
APP_HOST: 0.0.0.0 | ||
PHX_HOST: 0.0.0.0 | ||
SECRET_KEY_BASE: some-secret-key | ||
STAGE: local | ||
# Postgres env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: CD-dev | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["CI"] | ||
branches: [dev] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
on-success: | ||
runs-on: ubuntu-22.04 | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: Cloning repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Push to dokku | ||
uses: dokku/github-action@master | ||
with: | ||
# specify the `main` branch as the remote branch to push to | ||
branch: 'main' | ||
git_remote_url: ${{ secrets.SSH_REMOTE_DEV_URL }} | ||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
on-failure: | ||
runs-on: ubuntu-20.04 | ||
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | ||
steps: | ||
- run: echo 'The triggering workflow failed' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,12 @@ name: CI | |
|
||
on: | ||
# This action is triggered on any branch that opens a pull request. | ||
push: | ||
branches: | ||
- "*" | ||
# This action is not triggered when markdown files are modified. | ||
paths-ignore: | ||
- '**.md' | ||
pull_request: | ||
branches: | ||
- "*" | ||
|
@@ -22,6 +28,10 @@ env: | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | ||
POSTGRES_USER: ${{ secrets.POSTGRES_USER }} | ||
POSTGRES_HOSTNAME: localhost | ||
# Redis env | ||
REDIS_HOST: localhost | ||
REDIS_PORT: 6379 | ||
REDIS_PASS: ${{ secrets.REDIS_PASS }} | ||
# Misc env | ||
UPLOADS_PATH: "priv/static/uploads/" | ||
|
||
|
@@ -33,15 +43,29 @@ jobs: | |
image: postgres | ||
ports: ['5432:5432'] | ||
env: | ||
POSTGRES_USER: ${{ env.POSTGRES_USER }} | ||
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
# Setup & run Redis ----------------------------------------------------- | ||
- name: Run redis with a password | ||
shell: bash | ||
run: | | ||
docker run \ | ||
--rm \ | ||
--name redis \ | ||
-p ${{ env.REDIS_PORT }}:6379 \ | ||
-d redis:6-alpine redis-server \ | ||
--appendonly yes \ | ||
--requirepass ${{ env.REDIS_PASS }} \ | ||
--port ${{ env.REDIS_PORT }} | ||
# Run the dev action ---------------------------------------------------- | ||
- uses: actions/[email protected] | ||
- name: Run Development Checks | ||
uses: ./.github/actions/dev | ||
|
@@ -50,9 +74,11 @@ jobs: | |
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }} | ||
MIX_ENV: dev | ||
OTP_VERSION: ${{ env.OTP_VERSION }} | ||
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | ||
POSTGRES_USER: ${{ env.POSTGRES_USER }} | ||
UPLOADS_PATH: priv/static/uploads/ | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_USER: postgres | ||
REDIS_HOST: ${{ env.REDIS_HOST }} | ||
REDIS_PASS: ${{ env.REDIS_PASS }} | ||
UPLOADS_PATH: ${{ env.UPLOADS_PATH }} | ||
|
||
test: | ||
runs-on: ubuntu-22.04 | ||
|
@@ -61,15 +87,29 @@ jobs: | |
image: postgres | ||
ports: ['5432:5432'] | ||
env: | ||
POSTGRES_USER: ${{ env.POSTGRES_USER }} | ||
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
# Setup & run Redis ----------------------------------------------------- | ||
- name: Run redis with a password | ||
shell: bash | ||
run: | | ||
docker run \ | ||
--rm \ | ||
--name redis \ | ||
-p ${{ env.REDIS_PORT }}:6379 \ | ||
-d redis:6-alpine redis-server \ | ||
--appendonly yes \ | ||
--requirepass ${{ env.REDIS_PASS }} \ | ||
--port ${{ env.REDIS_PORT }} | ||
# Run the test action --------------------------------------------------- | ||
- uses: actions/[email protected] | ||
- name: Run Unit Tests | ||
uses: ./.github/actions/test | ||
|
@@ -78,9 +118,11 @@ jobs: | |
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }} | ||
MIX_ENV: test | ||
OTP_VERSION: ${{ env.OTP_VERSION }} | ||
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | ||
POSTGRES_USER: ${{ env.POSTGRES_USER }} | ||
UPLOADS_PATH: priv/static/uploads/ | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_USER: postgres | ||
REDIS_HOST: ${{ env.REDIS_HOST }} | ||
REDIS_PASS: ${{ env.REDIS_PASS }} | ||
UPLOADS_PATH: ${{ env.UPLOADS_PATH }} | ||
|
||
prod: | ||
runs-on: ubuntu-22.04 | ||
|
@@ -109,4 +151,6 @@ jobs: | |
POSTGRES_HOSTNAME: ${{ env.POSTGRES_HOSTNAME }} | ||
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | ||
POSTGRES_USER: ${{ env.POSTGRES_USER }} | ||
UPLOADS_PATH: priv/static/uploads/ | ||
REDIS_HOST: ${{ env.REDIS_HOST }} | ||
REDIS_PASS: ${{ env.REDIS_PASS }} | ||
UPLOADS_PATH: ${{ env.UPLOADS_PATH }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,4 @@ npm-debug.log | |
|
||
# Env | ||
.env | ||
.env.prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.