Skip to content

Instantly share code, notes, and snippets.

@ralphschindler
Created May 1, 2025 13:54
Show Gist options
  • Select an option

  • Save ralphschindler/4298cc3fc4a22a99a409a925e62d1fb7 to your computer and use it in GitHub Desktop.

Select an option

Save ralphschindler/4298cc3fc4a22a99a409a925e62d1fb7 to your computer and use it in GitHub Desktop.

Revisions

  1. ralphschindler created this gist May 1, 2025.
    37 changes: 37 additions & 0 deletions push-to-master-deploy.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    name: Push To Master Deploy

    on:
    push:
    branches:
    - master

    jobs:
    deploy-to-server:
    name: Deploy To Server
    runs-on: ubuntu-latest

    steps:
    - name: Add public IP to AWS security group
    uses: sohelamin/aws-security-group-add-ip-action@master
    with:
    aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
    aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    aws-region: 'us-east-1'
    aws-security-group-id: ${{ secrets.AWS_SECURITY_GROUP_ID }}
    port: '22'
    to-port: '30'
    protocol: 'tcp'
    description: 'GitHub Action'
    - name: Run SSH Deployment Script
    uses: appleboy/ssh-action@master
    with:
    host: 1.2.3.4 # REPLACE your instance IP address
    username: ubuntu
    key: ${{ secrets.SERVER_SSH_KEY }}
    script: |
    cd project-directory # REPLACE with directory on server
    git fetch origin
    git rebase origin master
    docker-compose -f docker-compose.production.yml exec -T web composer -q install --no-dev --ignore-platform-reqs
    docker-compose -f docker-compose.production.yml exec -T web artisan config:cache -q
    docker-compose -f docker-compose.production.yml exec -T web composer -q run restart-php