Skip to content

Commit 637c222

Browse files
committed
final touches for deploy
1 parent d106100 commit 637c222

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
test:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- name: Checkout
14+
- name: Checkout Code
1515
uses: actions/checkout@v6
1616

1717
- name: Set up Python
@@ -22,12 +22,11 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
25-
pip install -r requirements.txt
26-
pip install pytest pytest-asyncio testcontainers
25+
pip install -r requirements.txt pytest pytest-asyncio testcontainers
2726
2827
- name: Run tests
2928
run: |
30-
python -m pytest tests/ -v --ignore=tests/test_database_neo4j.py
29+
python -m pytest tests/ -v
3130
3231
deploy:
3332
needs: test
@@ -41,12 +40,13 @@ jobs:
4140
- name: Configure AWS Credentials
4241
uses: aws-actions/configure-aws-credentials@v6
4342
with:
44-
role-to-assume: arn:aws:iam::374169031176:role/GitHubActionSSMRole
45-
aws-region: ap-southeast-1
43+
role-to-assume: ${{ vars.AWS_ROLE }}
44+
aws-region: ${{ vars.AWS_REGION }}
4645

4746
- name: Create Deployment Script
4847
run: |
4948
cat << 'EOF' > deploy_script.sh
49+
set -e
5050
cd /opt/openpecha-backend || exit 1
5151
5252
git fetch origin ${{ github.ref_name }}
@@ -67,11 +67,9 @@ jobs:
6767
OTEL_EXPORTER_OTLP_HEADERS=${{ secrets.OTEL_EXPORTER_OTLP_HEADERS }}
6868
ENV_EOF
6969
70-
bash << 'APP_EOF'
7170
[ -d ".venv" ] || python3 -m venv .venv
7271
source .venv/bin/activate
7372
pip install -r requirements.txt
74-
APP_EOF
7573
7674
sudo systemctl restart openpecha-api
7775
EOF
@@ -89,12 +87,12 @@ jobs:
8987
9088
echo "Deployment started on ${{ vars.EC2_INSTANCE_ID }}. Command ID: $COMMAND_ID"
9189
92-
# Wait for the command to finish. If it fails, capture the exit code.
90+
# Wait for the command to finish and capture status
9391
aws ssm wait command-executed \
9492
--command-id "$COMMAND_ID" \
9593
--instance-id "${{ vars.EC2_INSTANCE_ID }}" || export EXIT_CODE=$?
9694
97-
# If it failed, fetch and print the actual error logs from the EC2 instance
95+
# If the deployment failed, fetch the actual error logs from the EC2
9896
if [ "${EXIT_CODE}" != "" ]; then
9997
echo "❌ Deployment Failed. Fetching remote logs..."
10098
aws ssm get-command-invocation \

0 commit comments

Comments
 (0)