Update README.md #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Open edX to AWS EC2 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up SSH | |
uses: webfactory/ssh-agent@v0.5.3 | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Set up AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-south-1 | |
- name: Deploy changes to EC2 | |
run: | | |
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@${{ secrets.EC2_IP_ADDRESS }} << 'EOF' | |
# Ensure Tutor is set up correctly | |
TUTOR_ROOT=$(tutor config printroot) | |
# Navigate to the theme directory using theme from GitHub secret | |
cd "$TUTOR_ROOT/env/build/openedx/themes/${{ secrets.THEME_NAME }}" | |
# Pull the latest changes from the master branch | |
git pull origin master | |
# Check if EDX_PLATFORM_REPOSITORY and EDX_PLATFORM_VERSION secrets are set | |
if [ -n "${{ secrets.EDX_PLATFORM_REPOSITORY }}" ] && [ -n "${{ secrets.EDX_PLATFORM_VERSION }}" ]; then | |
# Build Open edX images with optional repository and version | |
tutor images build openedx \ | |
--build-arg EDX_PLATFORM_REPOSITORY=${{ secrets.EDX_PLATFORM_REPOSITORY }} \ | |
--build-arg EDX_PLATFORM_VERSION=${{ secrets.EDX_PLATFORM_VERSION }} \ | |
--no-cache | |
else | |
# Default build without repository and version arguments | |
tutor images build openedx --no-cache | |
fi | |
# Restart services with the new changes | |
tutor local start -d | |
EOF |