Files
iptv-manager-service/.gitea/workflows/aws_deploy_on_push.yml
Stefano 4b1a7e9bea
All checks were successful
AWS Deploy on Push / build (push) Successful in 1m7s
Added alembic upgrade head to workflow script
2025-05-26 21:43:44 -05:00

80 lines
2.8 KiB
YAML

name: AWS Deploy on Push
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo "This job is now running on a ${{ runner.os }} server hosted by git.fiorinis.com!"
- run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- run: echo "The ${{ gitea.repository }} repository has been cloned to the runner."
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "22.15"
- name: Install Python dependencies and CDK
run: |
python -m pip install --upgrade pip
pip install aws-cdk-lib constructs
npm install -g aws-cdk
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@master
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: "us-east-2"
- name: Deploy to AWS
run: cdk deploy --app="python3 ${PWD}/app.py" --require-approval=never
env:
FREEDNS_User: ${{ secrets.FREEDNS_USER }}
FREEDNS_Password: ${{ secrets.FREEDNS_PASSWORD }}
DOMAIN_NAME: ${{ secrets.DOMAIN_NAME }}
SSH_PUBLIC_KEY: ${{ secrets.SSH_PUBLIC_KEY }}
REPO_URL: ${{ secrets.REPO_URL }}
LETSENCRYPT_EMAIL: ${{ secrets.LETSENCRYPT_EMAIL }}
- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
aws --version
- name: Update application on instance
run: |
INSTANCE_IDS=$(aws ec2 describe-instances \
--region us-east-2 \
--filters "Name=tag:Name,Values=IptvUpdaterStack/IptvUpdaterInstance" \
"Name=instance-state-name,Values=running" \
--query "Reservations[].Instances[].InstanceId" \
--output text)
for INSTANCE_ID in $INSTANCE_IDS; do
aws ssm send-command \
--region us-east-2 \
--instance-ids "$INSTANCE_ID" \
--document-name "AWS-RunShellScript" \
--parameters 'commands=[
"cd /home/ec2-user/iptv-updater-aws",
"git pull",
"pip3 install -r requirements.txt",
"alembic upgrade head",
"sudo systemctl restart iptv-updater"
]'
done
- run: echo "This job's status is ${{ job.status }}."