DEV Community

Cover image for Auto Deploy Laravel with Deployer.yml sample With Github Runner
Teddy Zugana
Teddy Zugana

Posted on

Auto Deploy Laravel with Deployer.yml sample With Github Runner

create a File Deployer.yml sample for github workflow

# This is a basic workflow that is manually triggered

name: Manual workflow

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
  push:
    branches:
      - main
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  CodeCheckout:
    # The type of runner that the job will run on
    runs-on: self-hosted

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v4

  CodeCheckout2:
    # The type of runner that the job will run on
    runs-on: self-hosted

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

  PullProject:
    needs: CodeCheckout
    runs-on: self-hosted
    steps:
      - name: Run project
        run: |
          cd /var/www/html/api_mobile/
          git -c credential.helper='!f() { echo "username=git username"; echo "password= git password(token pass)"; }; f' pull origin main

      # Runs a single command using the runners shell
      - name: Build assets
        run: npm install && npm run build

      - name: Install PHP dependencies
        run: composer install --no-dev --optimize-autoloader

      - name: Clear cache
        run: php artisan clear-compiled

      - name: Recreate cache
        run: php artisan optimize

Enter fullscreen mode Exit fullscreen mode

Download

Create a folder

$ mkdir actions-runner && cd actions-runner

Download the latest runner package

$ curl -o actions-runner-linux-x64-2.320.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.320.0/actions-runner-linux-x64-2.320.0.tar.gz

Optional: Validate the hash

$ echo "93ac1b7ce743ee85b5d386f5c1787385ef07b3d7c728ff66ce0d3813d actions-runner-linux-x64-2.320.0.tar.gz" | shasum -a 256 -c

Extract the installer

$ tar xzf ./actions-runner-linux-x64-2.320.0.tar.gz

Configure

Create the runner and start the configuration experience:

export RUNNER_ALLOW_RUNASROOT="1"

RUNNER_ALLOW_RUNASROOT="1" ./config.sh --url https://github.com/repo --token BLLCPCGOV5JBDIDVTN45333HFM

Last step, run it!:

RUNNER_ALLOW_RUNASROOT="1" ./run.sh &

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay