Skip to content

Commit

Permalink
chore: update shell
Browse files Browse the repository at this point in the history
  • Loading branch information
BrooksYang committed Mar 23, 2024
1 parent c9c41c3 commit 76c4446
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,16 @@ jobs:
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_KEY }}
script: |
mkdir -p /opt/bingo
cd /opt/bingo || exit
app_name=bingo
mkdir -p /opt/${app_name}
cd /opt/${app_name} || exit
tar -xzvpf /tmp/bingo-docker.tar.gz -C ./
tar -xzvpf /tmp/${app_name}-docker.tar.gz -C ./
if [ ! -f .env ]; then
cp .env.example .env
fi
if [ ! -f config/bingo-apiserver.yaml ]; then
cp config/bingo-apiserver.example.yaml config/bingo-apiserver.yaml
if [ ! -f config/${app_name}-apiserver.yaml ]; then
cp config/${app_name}-apiserver.example.yaml config/${app_name}-apiserver.yaml
fi
if [ ! -f config/promtail.yaml ]; then
cp config/promtail.example.yaml config/promtail.yaml
Expand All @@ -136,9 +137,15 @@ jobs:
sed -i "s/APP_VERSION=.*/APP_VERSION=${{ env.VERSION }}/g" .env
fi
docker load </tmp/bingo-images.tar.gz
# Load and tag latest
loaded=$(docker load </tmp/${app_name}-images.tar.gz)
for image_with_version in $(echo "$loaded" | awk -F ': ' '{print $2}'); do
image=${image_with_version%:*}
docker tag "$image_with_version" "$image":latest
done
docker-compose up -d
rm /tmp/bingo*.tar.gz
rm config/bingo-apiserver.example.yaml
rm /tmp/${app_name}*.tar.gz
rm config/${app_name}-apiserver.example.yaml
rm config/promtail.example.yaml
21 changes: 11 additions & 10 deletions .github/workflows/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bingo
name: ${app_name}
path: |
_output/*tar.gz
Expand All @@ -96,7 +96,7 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: bingo
name: ${app_name}
path: ./

- name: Display structure of downloaded files
Expand All @@ -119,15 +119,16 @@ jobs:
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_KEY }}
script: |
mkdir -p /opt/bingo
cd /opt/bingo || exit
app_name=bingo
mkdir -p /opt/${app_name}
cd /opt/${app_name} || exit
tar -xzvpf /tmp/bingo-docker.tar.gz -C ./
tar -xzvpf /tmp/${app_name}-docker.tar.gz -C ./
if [ ! -f .env ]; then
cp .env.example .env
fi
if [ ! -f config/bingo-apiserver.yaml ]; then
cp config/bingo-apiserver.example.yaml config/bingo-apiserver.yaml
if [ ! -f config/${app_name}-apiserver.yaml ]; then
cp config/${app_name}-apiserver.example.yaml config/${app_name}-apiserver.yaml
fi
if [ ! -f config/promtail.yaml ]; then
cp config/promtail.example.yaml config/promtail.yaml
Expand All @@ -139,14 +140,14 @@ jobs:
fi
# Load and tag latest
loaded=$(docker load </tmp/bingo-images.tar.gz)
loaded=$(docker load </tmp/${app_name}-images.tar.gz)
for image_with_version in $(echo "$loaded" | awk -F ': ' '{print $2}'); do
image=${image_with_version%:*}
docker tag "$image_with_version" "$image":latest
done
docker-compose up -d

rm /tmp/bingo*.tar.gz
rm config/bingo-apiserver.example.yaml
rm /tmp/${app_name}*.tar.gz
rm config/${app_name}-apiserver.example.yaml
rm config/promtail.example.yaml
2 changes: 1 addition & 1 deletion build/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ services:
- ${DATA_PATH_HOST}/log/bot:/opt/bingo/storage/log

# add alias to zsh to run bingoctl cmd.
# alias bingoctl="docker run --rm -v /path/to/config:/etc/bingo --network bingo_bingo bingoctl:{tag}"
# alias bingoctl="docker run --rm -v /path/to/config:/etc/bingo --network bingo_bingo bingoctl"
bingoctl:
image: ${APP_NAME}ctl:${APP_VERSION}
container_name: ${APP_NAME}ctl
Expand Down
17 changes: 9 additions & 8 deletions scripts/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
tag=$1

run() {
mkdir -p /opt/bingo
cd /opt/bingo || exit
app_name=bingo
mkdir -p /opt/${app_name}
cd /opt/${app_name} || exit

tar -xzvpf /tmp/bingo-docker.tar.gz -C ./
tar -xzvpf /tmp/${app_name}-docker.tar.gz -C ./
if [ ! -f .env ]; then
cp .env.example .env
fi
if [ ! -f config/bingo-apiserver.yaml ]; then
cp config/bingo-apiserver.example.yaml config/bingo-apiserver.yaml
if [ ! -f config/${app_name}-apiserver.yaml ]; then
cp config/${app_name}-apiserver.example.yaml config/${app_name}-apiserver.yaml
fi
if [ ! -f config/promtail.yaml ]; then
cp config/promtail.example.yaml config/promtail.yaml
Expand All @@ -24,16 +25,16 @@ run() {
fi

# Load and tag latest
loaded=$(docker load </tmp/bingo-images.tar.gz)
loaded=$(docker load </tmp/${app_name}-images.tar.gz)
for image_with_version in $(echo "$loaded" | awk -F ': ' '{print $2}'); do
image=${image_with_version%:*}
docker tag "$image_with_version" "$image":latest
done

docker-compose up -d

rm /tmp/bingo*.tar.gz
rm config/bingo-apiserver.example.yaml
rm /tmp/${app_name}*.tar.gz
rm config/${app_name}-apiserver.example.yaml
rm config/promtail.example.yaml
}

Expand Down

0 comments on commit 76c4446

Please sign in to comment.