Skip to content

Commit

Permalink
chore: add local orb prod test env
Browse files Browse the repository at this point in the history
  • Loading branch information
cao7113 committed Jul 4, 2024
1 parent afe8532 commit f11eac3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 27 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
export GIT_COMMIT_TIME=$(git log -1 --format="%ct")
MIX_ENV=prod RELEASE_TAR=1 mix release
# https://github.com/softprops/action-gh-release
- name: Make Github release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -89,7 +90,7 @@ jobs:
# vsn=${{ github.ref_name }}
# git_repo=${{ github.repository }}

# app_root=~/hello
# app_root=~/hello-api-elixir
# script_path=${app_root}/deploy.sh

# mkdir -p $app_root
Expand All @@ -102,4 +103,4 @@ jobs:
# echo "Use existed deploy-script: ${script_path}, manually delete it when need update"
# fi

# $script_path $vsn $app_root bin/hello_api ${git_repo} 3
# $script_path $vsn bin/hello_api ${git_repo} 3
15 changes: 3 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,21 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline

## [v0.1.4](https://github.com/cao7113/hello-api-elixir/compare/v0.1.3...v0.1.4) (2024-07-03)




### Bug Fixes:

* release-bar action missing env
- release-bar action missing env

## [v0.1.3](https://github.com/cao7113/hello-api-elixir/compare/v0.1.2...v0.1.3) (2024-07-03)




### Bug Fixes:

* try add release tar to github packages
- try add release tar to github releases

## [v0.1.2](https://github.com/cao7113/hello-api-elixir/compare/v0.1.1...v0.1.2) (2024-07-03)




### Bug Fixes:

* add fly deploy by github actions and fix text
- add fly deploy by github actions and fix text

## [v0.1.1](https://github.com/cao7113/hello-api-elixir/compare/v0.1.0...v0.1.1) (2024-07-03)

Expand Down
20 changes: 15 additions & 5 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# https://taskfile.dev
version: "3"

includes:
# fly related tasks
fly-io:
taskfile: ./Taskfile-fly-io.yml
aliases: [f, fly]
optional: true

tasks:
default: mix test --no-start

Expand All @@ -25,14 +28,21 @@ tasks:
get-info: curl -v http://localhost:4000 | jq
get-user: curl -s http://localhost:4000/users/123

## Docker images
dk-builder: docker pull hexpm/elixir:1.17.1-erlang-27.0-debian-bullseye-20240612-slim
dk-runner: docker pull debian:bullseye-20240612-slim

## Git ops
cmt: mix git_ops.release
cmt: mix git_ops.release && git push --follow-tags
app-info: mix git_ops.project_info
init-release: mix git_ops.release --initial

## Local prod env in Orbstack
# run `orb` into default ubuntu env, now in current project path
# run: `run/setup.sh _build/prod-orb` to setup deploy.sh
# run: `_build/prod-orb/deploy.sh v0.1.4` to deploy a version from github vsn release
# current release at: _build/prod-orb/current
# Visit by: http://ubox1.orb.local:4000/

## Docker env
dk-builder: docker pull hexpm/elixir:1.17.1-erlang-27.0-debian-bullseye-20240612-slim
dk-runner: docker pull debian:bullseye-20240612-slim

# Init setup
mk-hello: mix new hello-api-elixir --app hello_api --sup
18 changes: 13 additions & 5 deletions run/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#! /usr/bin/env sh
set -e

# ~/hello/deploy.sh v0.1.34 ~/hello bin/hello_api cao7113/hello-api-elixir 3
if [ $# -lt 1 ]; then
cat <<EOF
Usage:
$0 VSN # BIN_PATH GIT_REPO KEEP_LIMIT"
eg. ~/hello-api-elixir/deploy.sh v0.1.0 # bin/hello_api cao7113/hello-api-elixir 3
EOF
exit 1
fi

vsn=$1
app_root=${2:-~/hello}
bin_path=${3:-bin/hello_api}
git_repo=${4:-cao7113/hello-api-elixir}
keep_limit=${5:-3}
bin_path=${2:-bin/hello_api}
git_repo=${3:-cao7113/hello-api-elixir}
keep_limit=${4:-3}

app_root=$(realpath $(dirname $0))
bin_name=$(basename $bin_path)
bare_vsn=$(echo $vsn | sed 's/^v//')
vsn_dir=${app_root}/$vsn
Expand Down
8 changes: 5 additions & 3 deletions run/setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env sh
set -e

app_root=~/hello
app_root=${1:-_build/prod-orb}
mkdir -p $app_root
script_path=${app_root}/deploy.sh
git_repo=cao7113/hello-api-elixir

Expand All @@ -11,8 +13,8 @@ if [ ! -e $script_path ]; then
chmod +x $script_path
echo "Setup deploy-script into ${script_path} from ${script_url}"
else
echo "Use existed deploy-script: ${script_path}, manually delete it when need update"
echo "Use existed deploy-script: ${script_path}, manually delete it if need update!!"
fi

echo "## Deploy as following"
echo "$script_path v0.1.35 $app_root bin/hello_api cao7113/hello-api-elixir 3"
echo "$script_path v0.0.0 # $app_root bin/hello_api cao7113/hello-api-elixir 3"

0 comments on commit f11eac3

Please sign in to comment.