Skip to content

Commit

Permalink
ci: pass env vars to SSH-action context
Browse files Browse the repository at this point in the history
  • Loading branch information
bolinocroustibat committed May 17, 2024
1 parent b70fb3d commit 7d4702c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
18 changes: 18 additions & 0 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 Down
21 changes: 21 additions & 0 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 @@ -71,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 7d4702c

Please sign in to comment.