Repository navigation
chore: weekly dependency security update 2026-10-26 #76
Workflow file for this run
This file contains hidden or 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 Backend to AWS Lightsail | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - main | |
| paths: | |
| - 'backend/**' | |
| workflow_dispatch: # Add this to allow manual runs | |
| inputs: | |
| environment: | |
| description: 'Deployment environment' | |
| required: false | |
| default: 'test' | |
| jobs: | |
| build-and-deploy: | |
| if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./backend | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/aspc-backend:latest | |
| platforms: linux/amd64 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-west-2 | |
| - name: Install Lightsail Control plugin | |
| run: | | |
| curl "https://s3.us-west-2.amazonaws.com/lightsailctl/latest/linux-amd64/lightsailctl" -o "lightsailctl" | |
| chmod +x ./lightsailctl | |
| sudo mv ./lightsailctl /usr/local/bin/lightsailctl | |
| - name: Create deployment configuration | |
| run: | | |
| cat > containers.json << EOF | |
| { | |
| "backend": { | |
| "image": "${{ secrets.DOCKERHUB_USERNAME }}/aspc-backend:latest", | |
| "ports": { | |
| "5000": "HTTP" | |
| }, | |
| "environment": { | |
| "ENTITY_ID": "https://api.pomonastudents.org", | |
| "FRONTEND_LINK": "https://pomonastudents.org", | |
| "NEXT_PUBLIC_TINYMCE_API_KEY": "${{ secrets.TINYMCE_API_KEY }}", | |
| "SESSION_SECRET": "${{ secrets.SESSION_SECRET }}", | |
| "MONGODB_URI": "${{ secrets.MONGODB_URI }}", | |
| "NODE_ENV": "production", | |
| "PORT": "5000", | |
| "IDP_METADATA_URL": "${{ secrets.IDP_METADATA_URL }}", | |
| "ENGAGE_API_KEY": "${{ secrets.ENGAGE_API_KEY }}", | |
| "ENGAGE_API_URL": "${{ secrets.ENGAGE_API_URL }}" | |
| } | |
| } | |
| } | |
| EOF | |
| cat > public-endpoint.json << EOF | |
| { | |
| "containerName": "backend", | |
| "containerPort": 5000, | |
| "healthCheck": { | |
| "path": "/", | |
| "timeoutSeconds": 2, | |
| "intervalSeconds": 5, | |
| "successCodes": "200-499", | |
| "healthyThreshold": 2, | |
| "unhealthyThreshold": 2 | |
| } | |
| } | |
| EOF | |
| - name: Deploy to Lightsail | |
| run: | | |
| aws lightsail create-container-service-deployment \ | |
| --service-name aspc-backend-v1 \ | |
| --containers file://containers.json \ | |
| --public-endpoint file://public-endpoint.json | |
| echo "Deployment initiated. Check the AWS Lightsail console for status." |