Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bolinocroustibat committed May 17, 2024
1 parent d843dbc commit 4712a3c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 23 deletions.
29 changes: 18 additions & 11 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ jobs:
cp ./Dockerfile ./${{ env.CI_JOB_ID }}/Dockerfile
cp ./pyproject.toml ./${{ env.CI_JOB_ID }}/pyproject.toml
- name: Create .env file with current secrets
run: |
cd ./${{ env.CI_JOB_ID }}
touch .env
echo API_ENDPOINT="https://xxx.execute-api.us-west-2.amazonaws.com" >> .env
echo API_KEY=${{ secrets.API_KEY }} >> .env
echo MATRIX_HOME_SERVER=${{ secrets.MATRIX_HOME_SERVER }} >> .env
echo MATRIX_BOT_USERNAME=${{ secrets.MATRIX_BOT_USERNAME }} >> .env
echo MATRIX_BOT_PASSWORD=${{ secrets.MATRIX_BOT_PASSWORD }} >> .env
echo ERRORS_ROOM_ID=${{ secrets.ERRORS_ROOM_ID }} >> .env
echo USER_ALLOWED_DOMAINS=${{ secrets.USER_ALLOWED_DOMAINS }} >> .env
echo SALT=${{ secrets.SALT }} >> .env
echo ALBERT_API_URL=${{ secrets.ALBERT_API_URL }} >> .env
echo ALBERT_API_TOKEN=${{ secrets.ALBERT_API_TOKEN }} >> .env
echo ALBERT_API_MODEL_NAME=${{ secrets.ALBERT_API_MODEL_NAME }} >> .env
echo ALBERT_API_MODE=${{ secrets.ALBERT_API_MODE }} >> .env
cat .env
- name: Copy deployment files to remote server via SCP
uses: appleboy/scp-action@master
with:
Expand All @@ -58,17 +76,6 @@ jobs:

- name: Execute server commands for deploy
uses: appleboy/ssh-action@master
env:
MATRIX_HOME_SERVER: ${{ secrets.MATRIX_HOME_SERVER }}
MATRIX_BOT_USERNAME: ${{ secrets.MATRIX_BOT_USERNAME }}
MATRIX_BOT_PASSWORD: ${{ secrets.MATRIX_BOT_PASSWORD }}
ERRORS_ROOM_ID: ${{ secrets.ERRORS_ROOM_ID }}
USER_ALLOWED_DOMAINS: ${{ secrets.USER_ALLOWED_DOMAINS }}
SALT: ${{ secrets.SALT }}
ALBERT_API_URL: ${{ secrets.ALBERT_API_URL }}
ALBERT_API_TOKEN: ${{ secrets.ALBERT_API_TOKEN }}
ALBERT_API_MODEL_NAME: ${{ secrets.ALBERT_API_MODEL_NAME }}
ALBERT_API_MODE: ${{ secrets.ALBERT_API_MODE }}
with:
host: ${{ secrets.CI_DEPLOY_HOST }}
username: ${{ secrets.CI_DEPLOY_USER }}
Expand Down
34 changes: 22 additions & 12 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ jobs:
cp ./Dockerfile ./${{ env.CI_JOB_ID }}/Dockerfile
cp ./pyproject.toml ./${{ env.CI_JOB_ID }}/pyproject.toml
- name: Create .env file with current secrets
run: |
cd ./${{ env.CI_JOB_ID }}
touch .env
echo API_ENDPOINT="https://xxx.execute-api.us-west-2.amazonaws.com" >> .env
echo API_KEY=${{ secrets.API_KEY }} >> .env
echo MATRIX_HOME_SERVER=${{ secrets.MATRIX_HOME_SERVER }} >> .env
echo MATRIX_BOT_USERNAME=${{ secrets.MATRIX_BOT_USERNAME }} >> .env
echo MATRIX_BOT_PASSWORD=${{ secrets.MATRIX_BOT_PASSWORD }} >> .env
echo ERRORS_ROOM_ID=${{ secrets.ERRORS_ROOM_ID }} >> .env
echo USER_ALLOWED_DOMAINS=${{ secrets.USER_ALLOWED_DOMAINS }} >> .env
echo SALT=${{ secrets.SALT }} >> .env
echo ALBERT_API_URL=${{ secrets.ALBERT_API_URL }} >> .env
echo ALBERT_API_TOKEN=${{ secrets.ALBERT_API_TOKEN }} >> .env
echo ALBERT_API_MODEL_NAME=${{ secrets.ALBERT_API_MODEL_NAME }} >> .env
echo ALBERT_API_MODE=${{ secrets.ALBERT_API_MODE }} >> .env
cat .env
- name: Copy deployment files to remote server via SCP
uses: appleboy/scp-action@master
with:
Expand All @@ -59,17 +77,6 @@ jobs:

- name: Execute server commands for deploy
uses: appleboy/ssh-action@master
env:
MATRIX_HOME_SERVER: ${{ secrets.MATRIX_HOME_SERVER }}
MATRIX_BOT_USERNAME: ${{ secrets.MATRIX_BOT_USERNAME }}
MATRIX_BOT_PASSWORD: ${{ secrets.MATRIX_BOT_PASSWORD }}
ERRORS_ROOM_ID: ${{ secrets.ERRORS_ROOM_ID }}
USER_ALLOWED_DOMAINS: ${{ secrets.USER_ALLOWED_DOMAINS }}
SALT: ${{ secrets.SALT }}
ALBERT_API_URL: ${{ secrets.ALBERT_API_URL }}
ALBERT_API_TOKEN: ${{ secrets.ALBERT_API_TOKEN }}
ALBERT_API_MODEL_NAME: ${{ secrets.ALBERT_API_MODEL_NAME }}
ALBERT_API_MODE: ${{ secrets.ALBERT_API_MODE }}
with:
host: ${{ secrets.CI_DEPLOY_HOST }}
username: ${{ secrets.CI_DEPLOY_USER }}
Expand All @@ -82,6 +89,9 @@ jobs:
export COMPOSE_PROJECT_NAME=albert-tchapbot
docker compose down
docker tag albert/tchapbot:latest albert/tchapbot:old || true
docker image rm albert/tchapbot:latest || true
docker compose up --detach
docker image rm albert/tchapbot:old || true
rm -rf /home/${{ secrets.CI_DEPLOY_USER }}/${{ env.CI_JOB_ID }}

0 comments on commit 4712a3c

Please sign in to comment.